vinishjail97 commented on code in PR #992: URL: https://github.com/apache/incubator-xtable/pull/992#discussion_r4394930583
########## xtable-spark-extensions/src/main/scala/org/apache/xtable/spark/extensions/XTableIndex.scala: ########## @@ -0,0 +1,103 @@ +/* + * 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.xtable.spark.extensions + +import java.util.{Collections, Properties} + +import org.apache.hadoop.fs.Path +import org.apache.spark.sql.SparkSession + +import org.apache.hudi.common.table.HoodieTableMetaClient + +import org.apache.xtable.conversion.{ + ConversionConfig, + ConversionController, + SourceTable, + TargetTable +} +import org.apache.xtable.hudi.HudiTargetConfig +import org.apache.xtable.hudi.index.HudiBackedSecondaryIndexReader +import org.apache.xtable.iceberg.IcebergConversionSourceProvider +import org.apache.xtable.model.storage.TableFormat +import org.apache.xtable.model.sync.SyncStatusCode + +/** + * The XTable index of an Iceberg table. The index is a Hudi table at the data path of the Iceberg + * table, built and kept current by a sync to a Hudi target with a secondary index on the column of + * the index definition, and read by [[HudiBackedSecondaryIndexReader]]. + */ +case class XTableIndex(spark: SparkSession, sourceTable: SourceTable, definition: IndexDefinition) { Review Comment: The reader from #935 works for any source format, but pruning stages the selected files through Iceberg's `scan-task-set-id`, so the rule is Iceberg only. Other formats would need their own way to restrict a scan's file list, which could be a follow-up. ########## xtable-spark-extensions/src/main/scala/org/apache/xtable/spark/extensions/XTableIndex.scala: ########## @@ -0,0 +1,103 @@ +/* + * 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.xtable.spark.extensions + +import java.util.{Collections, Properties} + +import org.apache.hadoop.fs.Path +import org.apache.spark.sql.SparkSession + +import org.apache.hudi.common.table.HoodieTableMetaClient + +import org.apache.xtable.conversion.{ + ConversionConfig, + ConversionController, + SourceTable, + TargetTable +} +import org.apache.xtable.hudi.HudiTargetConfig +import org.apache.xtable.hudi.index.HudiBackedSecondaryIndexReader +import org.apache.xtable.iceberg.IcebergConversionSourceProvider +import org.apache.xtable.model.storage.TableFormat +import org.apache.xtable.model.sync.SyncStatusCode + +/** + * The XTable index of an Iceberg table. The index is a Hudi table at the data path of the Iceberg + * table, built and kept current by a sync to a Hudi target with a secondary index on the column of + * the index definition, and read by [[HudiBackedSecondaryIndexReader]]. + */ +case class XTableIndex(spark: SparkSession, sourceTable: SourceTable, definition: IndexDefinition) { + + def reader: HudiBackedSecondaryIndexReader = + new HudiBackedSecondaryIndexReader(sourceTable, new IcebergConversionSourceProvider, spark) + + /** Syncs the index with the current snapshot of the table, and builds it if it does not exist. */ + def sync(): Unit = { + val properties = new Properties() + definition.options.foreach { case (key, value) => + properties.setProperty(key, value) + } + properties.setProperty(HudiTargetConfig.HUDI_TABLE_VERSION, "9") + properties.setProperty( + HudiTargetConfig.EXECUTION_ENGINE, + HudiTargetConfig.ExecutionEngine.SPARK.getConfigValue) + properties.setProperty(HudiTargetConfig.SECONDARY_INDEX_COLUMN, definition.column) Review Comment: Agreed, dropped in b57e1b83. The extensions are now read-only: CREATE/DROP/REFRESH INDEX and the sync are gone, the index is built by the sync job, and the rule uses it only when it is current. ########## xtable-spark-extensions/src/main/scala/org/apache/xtable/spark/extensions/plans/RefreshIndex.scala: ########## @@ -0,0 +1,29 @@ +/* + * 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.xtable.spark.extensions.plans + +import org.apache.spark.sql.catalyst.plans.logical.{LogicalPlan, UnaryCommand} + +/** {@code REFRESH INDEX name ON table}: syncs an index with the current snapshot of the table. */ Review Comment: Removed in b57e1b83 along with the other index commands. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
