-
Notifications
You must be signed in to change notification settings - Fork 117
feat: add file lister operator #4364
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
aglinxinyuan
wants to merge
22
commits into
main
Choose a base branch
from
xinyuan-dataset-selector
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
dc7909f
feat(dataset-selector): add dataset selector operator and property UI
aglinxinyuan dd0b690
update
aglinxinyuan d277b91
Merge branch 'main' into xinyuan-dataset-selector
aglinxinyuan 4b95eab
fix fmt
aglinxinyuan 9baf392
fix fmt
aglinxinyuan 1afbddb
fix fmt
aglinxinyuan 42c401c
fix fmt
aglinxinyuan 174c0d1
fix fmt
aglinxinyuan f356126
fix fmt
aglinxinyuan 5ca5520
Merge branch 'main' into xinyuan-dataset-selector
kunwp1 1daf312
refactor
aglinxinyuan ec67fd8
fix fmt
aglinxinyuan fc25f2d
fix fmt
aglinxinyuan a9d37f4
fix fmt
aglinxinyuan 5ca84f0
fix fmt
aglinxinyuan 78a7b97
fix fmt
aglinxinyuan d653941
fix fmt
aglinxinyuan ed2b3ec
fix fmt
aglinxinyuan 8eecefa
fix fmt
aglinxinyuan 27c53ee
fix fmt
aglinxinyuan efd2220
revert change
aglinxinyuan ae027e0
fix fmt
aglinxinyuan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
...n/scala/org/apache/texera/amber/operator/source/dataset/DatasetSelectorSourceOpDesc.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| package org.apache.texera.amber.operator.source.dataset | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonProperty | ||
| import com.kjetland.jackson.jsonSchema.annotations.JsonSchemaTitle | ||
| import org.apache.texera.amber.core.executor.OpExecWithClassName | ||
| import org.apache.texera.amber.core.tuple.{AttributeType, Schema} | ||
| import org.apache.texera.amber.core.virtualidentity.{ExecutionIdentity, WorkflowIdentity} | ||
| import org.apache.texera.amber.core.workflow.{OutputPort, PhysicalOp, SchemaPropagationFunc} | ||
| import org.apache.texera.amber.operator.LogicalOp | ||
| import org.apache.texera.amber.operator.metadata.{OperatorGroupConstants, OperatorInfo} | ||
| import org.apache.texera.amber.util.JSONUtils.objectMapper | ||
|
|
||
| class DatasetSelectorSourceOpDesc extends LogicalOp { | ||
|
|
||
| @JsonProperty(required = true) | ||
| @JsonSchemaTitle("Dataset") | ||
| var datasetVersionPath: String = _ | ||
|
|
||
| override def getPhysicalOp( | ||
| workflowId: WorkflowIdentity, | ||
| executionId: ExecutionIdentity | ||
| ): PhysicalOp = | ||
| PhysicalOp | ||
| .sourcePhysicalOp( | ||
| workflowId, | ||
| executionId, | ||
| operatorIdentifier, | ||
| OpExecWithClassName( | ||
| "org.apache.texera.amber.operator.source.dataset.DatasetSelectorSourceOpExec", | ||
| objectMapper.writeValueAsString(this) | ||
| ) | ||
| ) | ||
| .withInputPorts(operatorInfo.inputPorts) | ||
| .withOutputPorts(operatorInfo.outputPorts) | ||
| .withPropagateSchema( | ||
| SchemaPropagationFunc(_ => | ||
| Map(operatorInfo.outputPorts.head.id -> Schema().add("filename", AttributeType.STRING)) | ||
| ) | ||
| ) | ||
|
|
||
| override def operatorInfo: OperatorInfo = | ||
| OperatorInfo( | ||
| userFriendlyName = "Dataset Selector", | ||
| operatorDescription = "Select a dataset version and output one filename tuple per file", | ||
| operatorGroupName = OperatorGroupConstants.INPUT_GROUP, | ||
| inputPorts = List.empty, | ||
| outputPorts = List(OutputPort()) | ||
| ) | ||
| } |
60 changes: 60 additions & 0 deletions
60
...n/scala/org/apache/texera/amber/operator/source/dataset/DatasetSelectorSourceOpExec.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| package org.apache.texera.amber.operator.source.dataset | ||
|
|
||
| import org.apache.texera.amber.core.executor.SourceOperatorExecutor | ||
| import org.apache.texera.amber.core.storage.util.LakeFSStorageClient | ||
| import org.apache.texera.amber.core.tuple.TupleLike | ||
| import org.apache.texera.amber.util.JSONUtils.objectMapper | ||
| import org.apache.texera.dao.SqlServer | ||
| import org.apache.texera.dao.jooq.generated.tables.Dataset.DATASET | ||
| import org.apache.texera.dao.jooq.generated.tables.DatasetVersion.DATASET_VERSION | ||
| import org.apache.texera.dao.jooq.generated.tables.User.USER | ||
|
|
||
| class DatasetSelectorSourceOpExec private[dataset] (descString: String) | ||
| extends SourceOperatorExecutor { | ||
| private val desc: DatasetSelectorSourceOpDesc = | ||
| objectMapper.readValue(descString, classOf[DatasetSelectorSourceOpDesc]) | ||
|
|
||
| override def produceTuple(): Iterator[TupleLike] = { | ||
| val Seq(_, ownerEmail, datasetName, versionName) = | ||
| desc.datasetVersionPath.split("/").toSeq | ||
|
|
||
| val (repositoryName, versionHash) = | ||
| SqlServer | ||
| .getInstance() | ||
| .createDSLContext() | ||
| .select(DATASET.REPOSITORY_NAME, DATASET_VERSION.VERSION_HASH) | ||
| .from(DATASET) | ||
| .join(USER) | ||
| .on(USER.UID.eq(DATASET.OWNER_UID)) | ||
| .join(DATASET_VERSION) | ||
| .on(DATASET_VERSION.DID.eq(DATASET.DID)) | ||
| .where(USER.EMAIL.eq(ownerEmail)) | ||
| .and(DATASET.NAME.eq(datasetName)) | ||
| .and(DATASET_VERSION.NAME.eq(versionName)) | ||
| .fetchOne(r => (r.value1(), r.value2())) | ||
aglinxinyuan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| LakeFSStorageClient | ||
| .retrieveObjectsOfVersion(repositoryName, versionHash) | ||
| .map(obj => TupleLike("filename" -> s"${desc.datasetVersionPath}/${obj.getPath}")) | ||
| .iterator | ||
| } | ||
| } | ||
43 changes: 43 additions & 0 deletions
43
...ala/org/apache/texera/amber/operator/source/dataset/DatasetSelectorSourceOpDescSpec.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| package org.apache.texera.amber.operator.source.dataset | ||
|
|
||
| import org.apache.texera.amber.core.tuple.AttributeType | ||
| import org.scalatest.flatspec.AnyFlatSpec | ||
|
|
||
| class DatasetSelectorSourceOpDescSpec extends AnyFlatSpec { | ||
|
|
||
| "DatasetSelectorSourceOpDesc" should "expose a filename output column" in { | ||
| val opDesc = new DatasetSelectorSourceOpDesc() | ||
|
|
||
| val outputSchema = opDesc.getExternalOutputSchemas(Map.empty).values.head | ||
|
|
||
| assert(outputSchema.getAttributes.length == 1) | ||
| assert(outputSchema.getAttribute("filename").getType == AttributeType.STRING) | ||
| } | ||
|
|
||
| it should "use the expected operator metadata" in { | ||
| val opDesc = new DatasetSelectorSourceOpDesc() | ||
|
|
||
| assert(opDesc.operatorInfo.userFriendlyName == "Dataset Selector") | ||
| assert(opDesc.operatorInfo.inputPorts.isEmpty) | ||
| assert(opDesc.operatorInfo.outputPorts.length == 1) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.