Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ project(':iceberg-hive-metastore') {
}
}

project(':iceberg-hivelink') {
project(':iceberg-hivelink-core') {
dependencies {
compile project(':iceberg-hive-metastore')

Expand Down Expand Up @@ -872,7 +872,7 @@ if (jdkVersion == '8') {
compile project(':iceberg-arrow')
compile project(':iceberg-hive-metastore')
compile project(':iceberg-spark')
compile project(':iceberg-hivelink')
compile project(':iceberg-hivelink-core')

compileOnly "org.apache.avro:avro"
compileOnly("org.apache.spark:spark-hive_2.11") {
Expand Down Expand Up @@ -982,7 +982,7 @@ project(':iceberg-spark3') {
compile project(':iceberg-arrow')
compile project(':iceberg-hive-metastore')
compile project(':iceberg-spark')
compile project(':iceberg-hivelink')
compile project(':iceberg-hivelink-core')

compileOnly "org.apache.avro:avro"
compileOnly("org.apache.spark:spark-hive_2.12") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,9 @@ public final class HiveCatalogs {
private HiveCatalogs() {
}

private static final Cache<String, HiveMetadataPreservingCatalog> HIVE_METADATA_PRESERVING_CATALOG_CACHE =
Caffeine.newBuilder().build();

public static HiveCatalog loadCatalog(Configuration conf) {
// metastore URI can be null in local mode
String metastoreUri = conf.get(HiveConf.ConfVars.METASTOREURIS.varname, "");
return CATALOG_CACHE.get(metastoreUri, uri -> new HiveCatalog(conf));
}

/**
* @deprecated Use {@link #loadHiveMetadataPreservingCatalog(Configuration)} instead
*/
@Deprecated
public static HiveCatalog loadCustomCatalog(Configuration conf) {
return loadHiveMetadataPreservingCatalog(conf);
}

public static HiveCatalog loadHiveMetadataPreservingCatalog(Configuration conf) {
// metastore URI can be null in local mode
String metastoreUri = conf.get(HiveConf.ConfVars.METASTOREURIS.varname, "");
return HIVE_METADATA_PRESERVING_CATALOG_CACHE.get(metastoreUri, uri -> new HiveMetadataPreservingCatalog(conf));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

package org.apache.iceberg.hivelink;
package org.apache.iceberg.hivelink.core;

import org.apache.iceberg.FileFormat;
import org.apache.iceberg.StructLike;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

package org.apache.iceberg.hivelink;
package org.apache.iceberg.hivelink.core;

import java.time.Instant;
import java.time.OffsetDateTime;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,16 @@
* under the License.
*/

package org.apache.iceberg.hive;
package org.apache.iceberg.hivelink.core;

import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hive.conf.HiveConf;
import org.apache.iceberg.TableOperations;
import org.apache.iceberg.catalog.TableIdentifier;
import org.apache.iceberg.hadoop.HadoopFileIO;
import org.apache.iceberg.hive.HiveCatalog;


/**
Expand All @@ -37,11 +41,29 @@ public HiveMetadataPreservingCatalog(Configuration conf) {
super(conf);
}

private static final Cache<String, HiveMetadataPreservingCatalog> HIVE_METADATA_PRESERVING_CATALOG_CACHE =
Caffeine.newBuilder().build();

@Override
public TableOperations newTableOps(TableIdentifier tableIdentifier) {
String dbName = tableIdentifier.namespace().level(0);
String tableName = tableIdentifier.name();
return new HiveMetadataPreservingTableOperations(conf(), clientPool(), new HadoopFileIO(conf()), name(), dbName,
tableName);
}


/**
* @deprecated Use {@link #loadHiveMetadataPreservingCatalog(Configuration)} instead
*/
@Deprecated
public static HiveCatalog loadCustomCatalog(Configuration conf) {
return loadHiveMetadataPreservingCatalog(conf);
}

public static HiveCatalog loadHiveMetadataPreservingCatalog(Configuration conf) {
// metastore URI can be null in local mode
String metastoreUri = conf.get(HiveConf.ConfVars.METASTOREURIS.varname, "");
return HIVE_METADATA_PRESERVING_CATALOG_CACHE.get(metastoreUri, uri -> new HiveMetadataPreservingCatalog(conf));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

package org.apache.iceberg.hive;
package org.apache.iceberg.hivelink.core;

import java.net.UnknownHostException;
import java.util.Collections;
Expand All @@ -37,6 +37,8 @@
import org.apache.iceberg.exceptions.CommitFailedException;
import org.apache.iceberg.exceptions.CommitStateUnknownException;
import org.apache.iceberg.exceptions.NoSuchTableException;
import org.apache.iceberg.hive.HiveClientPool;
import org.apache.iceberg.hive.HiveTableOperations;
import org.apache.iceberg.io.FileIO;
import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap;
import org.apache.iceberg.relocated.com.google.common.collect.ImmutableSet;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

package org.apache.iceberg.hivelink;
package org.apache.iceberg.hivelink.core;

import java.util.List;
import org.apache.hadoop.hive.serde2.typeinfo.DecimalTypeInfo;
Expand All @@ -26,6 +26,7 @@
import org.apache.hadoop.hive.serde2.typeinfo.PrimitiveTypeInfo;
import org.apache.hadoop.hive.serde2.typeinfo.StructTypeInfo;
import org.apache.hadoop.hive.serde2.typeinfo.UnionTypeInfo;
import org.apache.iceberg.hivelink.core.utils.HiveTypeUtil;
import org.apache.iceberg.relocated.com.google.common.collect.Lists;
import org.apache.iceberg.types.Type;
import org.apache.iceberg.types.Types;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

package org.apache.iceberg.hivelink;
package org.apache.iceberg.hivelink.core;

import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

package org.apache.iceberg.hivelink;
package org.apache.iceberg.hivelink.core;

import java.util.List;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

package org.apache.iceberg.hivelink;
package org.apache.iceberg.hivelink.core;

import java.time.LocalDate;
import java.time.LocalDateTime;
Expand Down Expand Up @@ -50,6 +50,7 @@
import org.apache.iceberg.expressions.Expressions;
import org.apache.iceberg.hadoop.HadoopFileIO;
import org.apache.iceberg.hive.HiveClientPool;
import org.apache.iceberg.hivelink.core.utils.FileSystemUtils;
import org.apache.iceberg.io.FileIO;
import org.apache.iceberg.io.LocationProvider;
import org.apache.iceberg.mapping.MappingUtil;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

package org.apache.iceberg.hivelink;
package org.apache.iceberg.hivelink.core;

import org.apache.iceberg.BaseFileScanTask;
import org.apache.iceberg.DataTableScan;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

package org.apache.iceberg.hivelink;
package org.apache.iceberg.hivelink.core;

import java.util.HashMap;
import java.util.List;
Expand All @@ -37,6 +37,8 @@
import org.apache.iceberg.StructLike;
import org.apache.iceberg.avro.AvroSchemaUtil;
import org.apache.iceberg.avro.AvroSchemaVisitor;
import org.apache.iceberg.hivelink.core.schema.MergeHiveSchemaWithAvro;
import org.apache.iceberg.hivelink.core.utils.HiveTypeUtil;
import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
import org.apache.iceberg.relocated.com.google.common.collect.Lists;
import org.apache.iceberg.types.Conversions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

package org.apache.iceberg.hivelink;
package org.apache.iceberg.hivelink.core.schema;

import java.util.List;
import org.apache.hadoop.hive.serde2.typeinfo.ListTypeInfo;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

package org.apache.iceberg.hivelink;
package org.apache.iceberg.hivelink.core.schema;

import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -49,9 +49,9 @@
* 5. Fields found only in Hive schema are represented as optional fields in the resultant Avro schema
* 6. For fields found only in Hive schema, field names are sanitized to make them compatible with Avro identifier spec
*/
class MergeHiveSchemaWithAvro extends HiveSchemaWithPartnerVisitor<Schema, Schema.Field, Schema, Schema.Field> {
public class MergeHiveSchemaWithAvro extends HiveSchemaWithPartnerVisitor<Schema, Schema.Field, Schema, Schema.Field> {

static Schema visit(StructTypeInfo typeInfo, Schema schema) {
public static Schema visit(StructTypeInfo typeInfo, Schema schema) {
return visit(typeInfo, schema, new MergeHiveSchemaWithAvro(),
AvroPartnerAccessor.INSTANCE);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

package org.apache.iceberg.hivelink;
package org.apache.iceberg.hivelink.core.utils;

import java.io.IOException;
import java.io.UncheckedIOException;
Expand All @@ -30,15 +30,15 @@
import org.apache.hadoop.fs.PathFilter;
import org.apache.iceberg.exceptions.RuntimeIOException;

class FileSystemUtils {
public class FileSystemUtils {

private FileSystemUtils() {
}

/**
* Lists all non-hidden files for the given directory
*/
static List<FileStatus> listFiles(String directory, Configuration conf) {
public static List<FileStatus> listFiles(String directory, Configuration conf) {

final Path directoryPath = new Path(directory);
final FileStatus[] files;
Expand All @@ -51,7 +51,7 @@ static List<FileStatus> listFiles(String directory, Configuration conf) {
return Arrays.asList(files);
}

static boolean exists(String file, Configuration conf) {
public static boolean exists(String file, Configuration conf) {
final Path filePath = new Path(file);
try {
FileSystem fs = filePath.getFileSystem(conf);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

package org.apache.iceberg.hivelink;
package org.apache.iceberg.hivelink.core.utils;

import java.util.List;
import org.apache.hadoop.hive.serde2.typeinfo.ListTypeInfo;
Expand All @@ -26,6 +26,7 @@
import org.apache.hadoop.hive.serde2.typeinfo.StructTypeInfo;
import org.apache.hadoop.hive.serde2.typeinfo.TypeInfo;
import org.apache.hadoop.hive.serde2.typeinfo.UnionTypeInfo;
import org.apache.iceberg.hivelink.core.HiveTypeToIcebergType;
import org.apache.iceberg.relocated.com.google.common.collect.Lists;
import org.apache.iceberg.types.Type;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

package org.apache.iceberg.hivelink;
package org.apache.iceberg.hivelink.core;

import java.util.HashMap;
import org.apache.hadoop.hive.conf.HiveConf;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

package org.apache.iceberg.hivelink;
package org.apache.iceberg.hivelink.core;

import java.io.IOException;
import java.io.LineNumberReader;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

package org.apache.iceberg.hivelink;
package org.apache.iceberg.hivelink.core;

import org.apache.iceberg.expressions.Expression;
import org.apache.iceberg.relocated.com.google.common.collect.ImmutableSet;
Expand All @@ -35,7 +35,7 @@
import static org.apache.iceberg.expressions.Expressions.notIn;
import static org.apache.iceberg.expressions.Expressions.notNull;
import static org.apache.iceberg.expressions.Expressions.or;
import static org.apache.iceberg.hivelink.HiveExpressions.simplifyPartitionFilter;
import static org.apache.iceberg.hivelink.core.HiveExpressions.simplifyPartitionFilter;


public class TestHiveExpressions {
Expand Down
Loading