-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
560 additions
and
20 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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
37 changes: 37 additions & 0 deletions
37
...mmon/src/main/scala/org/apache/paimon/spark/catalyst/plans/logical/CreateTagCommand.scala
This file contains 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,37 @@ | ||
/* | ||
* 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.paimon.spark.catalyst.plans.logical | ||
|
||
import org.apache.paimon.spark.leafnode.PaimonLeafCommand | ||
|
||
import org.apache.spark.sql.catalyst.expressions.Attribute | ||
|
||
case class CreateTagCommand( | ||
table: Seq[String], | ||
tagName: String, | ||
tagOptions: TagOptions, | ||
ifNotExists: Boolean) | ||
extends PaimonLeafCommand { | ||
|
||
override def output: Seq[Attribute] = Nil | ||
|
||
override def simpleString(maxFields: Int): String = { | ||
s"Create tag: $tagName for table: $table" | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
...mmon/src/main/scala/org/apache/paimon/spark/catalyst/plans/logical/DeleteTagCommand.scala
This file contains 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,33 @@ | ||
/* | ||
* 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.paimon.spark.catalyst.plans.logical | ||
|
||
import org.apache.paimon.spark.leafnode.PaimonLeafCommand | ||
|
||
import org.apache.spark.sql.catalyst.expressions.Attribute | ||
|
||
case class DeleteTagCommand(table: Seq[String], tagStr: String, ifExists: Boolean) | ||
extends PaimonLeafCommand { | ||
|
||
override def output: Seq[Attribute] = Nil | ||
|
||
override def simpleString(maxFields: Int): String = { | ||
s"Delete tag: $tagStr for table: $table" | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
...mmon/src/main/scala/org/apache/paimon/spark/catalyst/plans/logical/RenameTagCommand.scala
This file contains 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,33 @@ | ||
/* | ||
* 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.paimon.spark.catalyst.plans.logical | ||
|
||
import org.apache.paimon.spark.leafnode.PaimonLeafCommand | ||
|
||
import org.apache.spark.sql.catalyst.expressions.{Attribute, AttributeReference} | ||
|
||
case class RenameTagCommand(table: Seq[String], sourceTag: String, targetTag: String) | ||
extends PaimonLeafCommand { | ||
|
||
override def output: Seq[Attribute] = Nil | ||
|
||
override def simpleString(maxFields: Int): String = { | ||
s"Rename tag from $sourceTag to $targetTag for table: $table" | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...ark-common/src/main/scala/org/apache/paimon/spark/catalyst/plans/logical/TagOptions.scala
This file contains 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,23 @@ | ||
/* | ||
* 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.paimon.spark.catalyst.plans.logical | ||
|
||
import java.time.Duration | ||
|
||
case class TagOptions(snapshotId: Option[Long], timeRetained: Option[Duration]) |
62 changes: 62 additions & 0 deletions
62
.../paimon-spark-common/src/main/scala/org/apache/paimon/spark/execution/CreateTagExec.scala
This file contains 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,62 @@ | ||
/* | ||
* 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.paimon.spark.execution | ||
|
||
import org.apache.paimon.spark.SparkTable | ||
import org.apache.paimon.spark.catalyst.plans.logical.TagOptions | ||
import org.apache.paimon.spark.leafnode.PaimonLeafV2CommandExec | ||
import org.apache.paimon.table.FileStoreTable | ||
|
||
import org.apache.spark.sql.catalyst.InternalRow | ||
import org.apache.spark.sql.catalyst.expressions.Attribute | ||
import org.apache.spark.sql.connector.catalog.{Identifier, TableCatalog} | ||
|
||
case class CreateTagExec( | ||
catalog: TableCatalog, | ||
ident: Identifier, | ||
tagName: String, | ||
tagOptions: TagOptions, | ||
ifNotExists: Boolean) | ||
extends PaimonLeafV2CommandExec { | ||
|
||
override protected def run(): Seq[InternalRow] = { | ||
val table = catalog.loadTable(ident) | ||
assert(table.isInstanceOf[SparkTable]) | ||
|
||
table.asInstanceOf[SparkTable].getTable match { | ||
case paimonTable: FileStoreTable => | ||
val tagIsExists = paimonTable.tagManager().tagExists(tagName) | ||
if (tagIsExists && ifNotExists) { | ||
return Nil | ||
} | ||
val timeRetained = tagOptions.timeRetained.orNull | ||
if (tagOptions.snapshotId.isEmpty) { | ||
paimonTable.createTag(tagName, timeRetained) | ||
} else { | ||
paimonTable.createTag(tagName, tagOptions.snapshotId.get, timeRetained) | ||
} | ||
case t => | ||
throw new UnsupportedOperationException( | ||
s"Can not create tag for non-paimon FileStoreTable: $t") | ||
} | ||
Nil | ||
} | ||
|
||
override def output: Seq[Attribute] = Nil | ||
} |
Oops, something went wrong.