the-other-tim-brown commented on code in PR #935:
URL: https://github.com/apache/incubator-xtable/pull/935#discussion_r4238832408


##########
xtable-api/src/main/java/org/apache/xtable/model/sync/SyncResult.java:
##########
@@ -50,6 +50,18 @@ public class SyncResult {
   // The sync status for each catalog.
   @Builder.Default List<CatalogSyncStatus> catalogSyncStatusList = 
Collections.emptyList();
 
+  /**
+   * Returns the error message of the table format sync of the given result, 
or null when the sync
+   * reported no error details.
+   */
+  public static String getErrorMessage(SyncResult syncResult) {

Review Comment:
   Can we just make this an instance method?



##########
xtable-core/src/main/java/org/apache/xtable/index/HudiBackedIcebergSecondaryIndex.java:
##########
@@ -0,0 +1,423 @@
+/*
+ * 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.index;
+
+import static 
org.apache.hudi.metadata.HoodieTableMetadataUtil.PARTITION_NAME_SECONDARY_INDEX_PREFIX;
+import static org.apache.spark.sql.functions.col;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import lombok.extern.log4j.Log4j2;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.spark.api.java.JavaPairRDD;
+import org.apache.spark.api.java.JavaRDD;
+import org.apache.spark.api.java.JavaSparkContext;
+import org.apache.spark.sql.Dataset;
+import org.apache.spark.sql.Encoders;
+import org.apache.spark.sql.Row;
+import org.apache.spark.sql.RowFactory;
+import org.apache.spark.sql.SparkSession;
+import org.apache.spark.sql.types.DataType;
+import org.apache.spark.sql.types.DataTypes;
+import org.apache.spark.sql.types.DateType;
+import org.apache.spark.sql.types.StructType;
+import org.apache.spark.sql.types.TimestampNTZType;
+import org.apache.spark.sql.types.TimestampType;
+
+import org.apache.hudi.client.common.HoodieSparkEngineContext;
+import org.apache.hudi.common.config.HoodieMetadataConfig;
+import org.apache.hudi.common.data.HoodiePairData;
+import org.apache.hudi.common.fs.FSUtils;
+import org.apache.hudi.common.table.HoodieTableMetaClient;
+import org.apache.hudi.common.table.HoodieTableVersion;
+import org.apache.hudi.data.HoodieJavaPairRDD;
+import org.apache.hudi.data.HoodieJavaRDD;
+import org.apache.hudi.exception.TableNotFoundException;
+import org.apache.hudi.metadata.HoodieBackedTableMetadata;
+import org.apache.hudi.storage.HoodieStorage;
+import org.apache.hudi.storage.hadoop.HoodieHadoopStorage;
+
+import org.apache.iceberg.Schema;
+import org.apache.iceberg.Table;
+import org.apache.iceberg.types.Type;
+import org.apache.iceberg.types.Types;
+
+import scala.Tuple2;
+
+import com.google.common.base.Preconditions;
+
+import org.apache.xtable.catalog.TableFormatUtils;
+import org.apache.xtable.conversion.ConversionConfig;
+import org.apache.xtable.conversion.ConversionController;
+import org.apache.xtable.conversion.SourceTable;
+import org.apache.xtable.conversion.TargetTable;
+import org.apache.xtable.hudi.HudiTargetConfig;
+import org.apache.xtable.iceberg.IcebergConversionSourceProvider;
+import org.apache.xtable.model.storage.TableFormat;
+import org.apache.xtable.model.sync.SyncResult;
+import org.apache.xtable.model.sync.SyncStatusCode;
+
+/**
+ * Secondary index for an Iceberg table backed by the Hudi metadata table. The 
index is built by
+ * syncing the Iceberg table to Hudi with the record index and a secondary 
index enabled; the Hudi

Review Comment:
   Is there anything specific to Iceberg that is required here? Generally as a 
project I would like us to allow any source to leverage the features of the 
target formats when possible.



##########
xtable-core/src/main/java/org/apache/xtable/index/Index.java:
##########
@@ -0,0 +1,56 @@
+/*
+ * 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.index;
+
+import org.apache.spark.sql.Dataset;
+import org.apache.spark.sql.Row;
+
+/**
+ * An index over a table that maps the values of a column to the rows that 
hold them, so an engine
+ * can find those rows without a full table scan or join.
+ *
+ * @param <T> The table type of the source format (for example an Iceberg 
{@code Table})
+ */
+public interface Index<T> {
+  /**
+   * Checks whether the index of the given column exists.
+   *
+   * @param columnName The indexed column
+   * @return true when a build of the index has completed
+   */
+  boolean doesIndexExist(String columnName);
+
+  /**
+   * Brings the indexes of the configured columns up to date with the current 
state of the table.
+   * The indexed columns are part of the index configuration, not of the sync.
+   *
+   * @param table The table to index
+   */
+  void syncIndex(T table);
+
+  /**
+   * Looks up the given keys in the index of a column.
+   *
+   * @param table The table the index belongs to
+   * @param keys The values to look up, in the column named {@code columnName}
+   * @param columnName The indexed column
+   * @return the matches of the keys. The schema of the result depends on the 
type of the index.
+   */
+  Dataset<Row> lookup(T table, Dataset<Row> keys, String columnName);

Review Comment:
   Does it make sense to split the lookup from the sync? This is introducing 
another dependency on Spark so I'd like to make sure we think through the 
design and structure of the code.



-- 
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]

Reply via email to