.setSystemProperty(JOIN_DISTRIBUTION_TYPE, "partitioned") .setSystemProperty(HASH_PARTITION_COUNT, "43") .setCatalogSessionProperty("testCatalog", "explicit_set", "explicit_set") .build();
private List<TestingHiveStorageFormat> getAllTestingHiveStorageFormat() { Session session = getSession(); ImmutableList.Builder<TestingHiveStorageFormat> formats = ImmutableList.builder(); for (HiveStorageFormat hiveStorageFormat : HiveStorageFormat.values()) { formats.add(new TestingHiveStorageFormat(session, hiveStorageFormat)); } formats.add(new TestingHiveStorageFormat( Session.builder(session).setCatalogSessionProperty(session.getCatalog().get(), "orc_optimized_writer_enabled", "true").build(), HiveStorageFormat.ORC)); formats.add(new TestingHiveStorageFormat( Session.builder(session).setCatalogSessionProperty(session.getCatalog().get(), "orc_optimized_writer_enabled", "true").build(), HiveStorageFormat.DWRF)); return formats.build(); }
String catalog = catalogProperties.getKey(); for (Entry<String, String> entry : catalogProperties.getValue().entrySet()) { sessionBuilder.setCatalogSessionProperty(catalog, entry.getKey(), entry.getValue());
.setCatalogSessionProperty(catalog, "optimize_mismatched_bucket_count", "true") .build(); Session withoutMismatchOptimization = Session.builder(getSession()) .setSystemProperty(COLOCATED_JOIN, "true") .setCatalogSessionProperty(catalog, "optimize_mismatched_bucket_count", "false") .build();
@Test public void testCastNullToColumnTypes() { String tableName = "test_cast_null_to_column_types"; Session session = Session.builder(getSession()) .setCatalogSessionProperty(catalog, "orc_optimized_writer_enabled", "true") .build(); assertUpdate(session, "" + "CREATE TABLE " + tableName + " (" + " col1 bigint," + " col2 map(bigint, bigint)," + " partition_key varchar)" + "WITH (" + " format = 'ORC', " + " partitioned_by = ARRAY[ 'partition_key' ] " + ")"); assertUpdate(session, format("INSERT INTO %s (col1) VALUES (1), (2), (3)", tableName), 3); assertUpdate("DROP TABLE " + tableName); }
private void testRcTextCharDecoding(boolean rcFileOptimizedWriterEnabled) { String catalog = getSession().getCatalog().get(); Session session = Session.builder(getSession()) .setCatalogSessionProperty(catalog, RCFILE_OPTIMIZED_WRITER_ENABLED, Boolean.toString(rcFileOptimizedWriterEnabled)) .build(); assertUpdate(session, "CREATE TABLE test_table_with_char_rc WITH (format = 'RCTEXT') AS SELECT CAST('khaki' AS CHAR(7)) char_column", 1); try { assertQuery(session, "SELECT * FROM test_table_with_char_rc WHERE char_column = 'khaki '", "VALUES (CAST('khaki' AS CHAR(7)))"); } finally { assertUpdate(session, "DROP TABLE test_table_with_char_rc"); } }
private List<TestingHiveStorageFormat> getAllTestingHiveStorageFormat() { Session session = getSession(); ImmutableList.Builder<TestingHiveStorageFormat> formats = ImmutableList.builder(); for (HiveStorageFormat hiveStorageFormat : HiveStorageFormat.values()) { formats.add(new TestingHiveStorageFormat(session, hiveStorageFormat)); } formats.add(new TestingHiveStorageFormat( Session.builder(session).setCatalogSessionProperty(session.getCatalog().get(), "orc_optimized_writer_enabled", "true").build(), HiveStorageFormat.ORC)); formats.add(new TestingHiveStorageFormat( Session.builder(session).setCatalogSessionProperty(session.getCatalog().get(), "orc_optimized_writer_enabled", "true").build(), HiveStorageFormat.DWRF)); return formats.build(); }
@Test public void testInsertPartitionedTableOverwriteExistingPartition() { testInsertPartitionedTableOverwriteExistingPartition( Session.builder(getSession()) .setCatalogSessionProperty(catalog, "insert_existing_partitions_behavior", "OVERWRITE") .build(), HiveStorageFormat.ORC); }
.setCatalogSessionProperty(catalog, "optimize_mismatched_bucket_count", "true") .build(); Session withoutMismatchOptimization = Session.builder(getSession()) .setSystemProperty(COLOCATED_JOIN, "true") .setCatalogSessionProperty(catalog, "optimize_mismatched_bucket_count", "false") .build();
.setCatalogSessionProperty(CATALOG_NAME, "baz", "blah") .build();
@Test public void testTemporaryStagingDirectorySessionProperties() { String tableName = "test_temporary_staging_directory_session_properties"; assertUpdate(format("CREATE TABLE %s(i int)", tableName)); Session session = Session.builder(getSession()) .setCatalogSessionProperty("hive", "temporary_staging_directory_enabled", "false") .build(); HiveInsertTableHandle hiveInsertTableHandle = getHiveInsertTableHandle(session, tableName); assertEquals(hiveInsertTableHandle.getLocationHandle().getWritePath(), hiveInsertTableHandle.getLocationHandle().getTargetPath()); session = Session.builder(getSession()) .setCatalogSessionProperty("hive", "temporary_staging_directory_enabled", "true") .setCatalogSessionProperty("hive", "temporary_staging_directory_path", "/tmp/custom/temporary-${USER}") .build(); hiveInsertTableHandle = getHiveInsertTableHandle(session, tableName); assertNotEquals(hiveInsertTableHandle.getLocationHandle().getWritePath(), hiveInsertTableHandle.getLocationHandle().getTargetPath()); assertTrue(hiveInsertTableHandle.getLocationHandle().getWritePath().toString().startsWith("file:/tmp/custom/temporary-")); assertUpdate("DROP TABLE " + tableName); }
@Test public void testCastNullToColumnTypes() { String tableName = "test_cast_null_to_column_types"; Session session = Session.builder(getSession()) .setCatalogSessionProperty(catalog, "orc_optimized_writer_enabled", "true") .build(); assertUpdate(session, "" + "CREATE TABLE " + tableName + " (" + " col1 bigint," + " col2 map(bigint, bigint)," + " partition_key varchar)" + "WITH (" + " format = 'ORC', " + " partitioned_by = ARRAY[ 'partition_key' ] " + ")"); assertUpdate(session, format("INSERT INTO %s (col1) VALUES (1), (2), (3)", tableName), 3); assertUpdate("DROP TABLE " + tableName); }
private void testRcTextCharDecoding(boolean rcFileOptimizedWriterEnabled) { String catalog = getSession().getCatalog().get(); Session session = Session.builder(getSession()) .setCatalogSessionProperty(catalog, RCFILE_OPTIMIZED_WRITER_ENABLED, Boolean.toString(rcFileOptimizedWriterEnabled)) .build(); assertUpdate(session, "CREATE TABLE test_table_with_char_rc WITH (format = 'RCTEXT') AS SELECT CAST('khaki' AS CHAR(7)) char_column", 1); try { assertQuery(session, "SELECT * FROM test_table_with_char_rc WHERE char_column = 'khaki '", "VALUES (CAST('khaki' AS CHAR(7)))"); } finally { assertUpdate(session, "DROP TABLE test_table_with_char_rc"); } }
@Test public void testInsertPartitionedTableOverwriteExistingPartition() { testInsertPartitionedTableOverwriteExistingPartition( Session.builder(getSession()) .setCatalogSessionProperty(catalog, "insert_existing_partitions_behavior", "OVERWRITE") .build(), HiveStorageFormat.ORC); }