Skip to content

Commit

Permalink
Add DDL support for Alpha format
Browse files Browse the repository at this point in the history
  • Loading branch information
sdruzkin authored and highker committed Dec 15, 2022
1 parent 07b00d2 commit 5a7e325
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ public enum HiveStorageFormat
com.facebook.hive.orc.OrcInputFormat.class.getName(),
com.facebook.hive.orc.OrcOutputFormat.class.getName(),
new DataSize(256, Unit.MEGABYTE)),
ALPHA(
"com.facebook.alpha.AlphaSerde",
"com.facebook.alpha.AlphaInputFormat",
"com.facebook.alpha.AlphaOutputFormat",
new DataSize(256, Unit.MEGABYTE)),
PARQUET(
ParquetHiveSerDe.class.getName(),
MapredParquetInputFormat.class.getName(),
Expand Down Expand Up @@ -161,7 +166,7 @@ public boolean equals(Object o)
return false;
}
SerdeAndInputFormat that = (SerdeAndInputFormat) o;
return serDe.equals(that.serDe) && inputFormat.equals(that.inputFormat);
return Objects.equals(serDe, that.serDe) && Objects.equals(inputFormat, that.inputFormat);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@
import static com.facebook.presto.hive.HiveQueryRunner.METASTORE_CONTEXT;
import static com.facebook.presto.hive.HiveSessionProperties.OFFLINE_DATA_DEBUG_MODE_ENABLED;
import static com.facebook.presto.hive.HiveSessionProperties.SORTED_WRITE_TO_TEMP_PATH_ENABLED;
import static com.facebook.presto.hive.HiveStorageFormat.ALPHA;
import static com.facebook.presto.hive.HiveStorageFormat.AVRO;
import static com.facebook.presto.hive.HiveStorageFormat.CSV;
import static com.facebook.presto.hive.HiveStorageFormat.DWRF;
Expand Down Expand Up @@ -576,7 +577,8 @@ private static RowExpression toRowExpression(String sql)
protected Set<HiveStorageFormat> createTableFormats = difference(
ImmutableSet.copyOf(HiveStorageFormat.values()),
// exclude formats that change table schema with serde
ImmutableSet.of(AVRO, CSV));
// exclude ALPHA because it does not support DML yet
ImmutableSet.of(AVRO, CSV, ALPHA));

private static final JoinCompiler JOIN_COMPILER = new JoinCompiler(MetadataManager.createTestMetadataManager(), new FeaturesConfig());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,10 @@ public void testTableCreation()
// CSV supports only unbounded VARCHAR type
continue;
}
if (storageFormat == HiveStorageFormat.ALPHA) {
// Alpha read/write is not supported yet
continue;
}
createTable(METASTORE_CONTEXT, temporaryCreateTable, storageFormat);
dropTable(temporaryCreateTable);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5875,6 +5875,29 @@ public void testRefreshMaterializedView()
assertQueryFails("REFRESH MATERIALIZED VIEW test_customer_view_5", ".*mismatched input '<EOF>'\\. Expecting: '\\.', 'WHERE'.*");
}

@Test
public void testAlphaFormatDdl()
{
assertUpdate("CREATE TABLE test_alpha_ddl_table (col1 bigint) WITH (format = 'ALPHA')");
assertUpdate("ALTER TABLE test_alpha_ddl_table ADD COLUMN col2 bigint");
assertUpdate("ALTER TABLE test_alpha_ddl_table DROP COLUMN col2");
assertUpdate("DROP TABLE test_alpha_ddl_table");

assertUpdate("CREATE TABLE test_alpha_ddl_partitioned_table (col1 bigint, ds VARCHAR) WITH (format = 'ALPHA', partitioned_by = ARRAY['ds'])");
assertUpdate("ALTER TABLE test_alpha_ddl_partitioned_table ADD COLUMN col2 bigint");
assertUpdate("ALTER TABLE test_alpha_ddl_partitioned_table DROP COLUMN col2");
assertUpdate("DROP TABLE test_alpha_ddl_partitioned_table");
}

@Test
public void testAlphaFormatDml()
{
assertUpdate("CREATE TABLE test_alpha_dml_partitioned_table (col1 bigint, ds VARCHAR) WITH (format = 'ALPHA', partitioned_by = ARRAY['ds'])");
// Alpha does not support DML yet
assertQueryFails("INSERT INTO test_alpha_dml_partitioned_table VALUES (1, '2022-01-01')", "Serializer does not exist: com.facebook.alpha.AlphaSerde");
assertUpdate("DROP TABLE test_alpha_dml_partitioned_table");
}

protected String retentionDays(int days)
{
return "";
Expand Down Expand Up @@ -5993,6 +6016,10 @@ private List<TestingHiveStorageFormat> getAllTestingHiveStorageFormat()
// CSV supports only unbounded VARCHAR type
continue;
}
if (hiveStorageFormat == HiveStorageFormat.ALPHA) {
// Alpha does not support DML yet
continue;
}
formats.add(new TestingHiveStorageFormat(session, hiveStorageFormat));
}
return formats.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ public void testAllFormats()
// CSV supports only unbounded VARCHAR type, which is not provided by lineitem
continue;
}
if (format == HiveStorageFormat.ALPHA) {
// Alpha read/write is not supported yet
continue;
}

config.setHiveStorageFormat(format);
config.setCompressionCodec(NONE);
long uncompressedLength = writeTestFile(config, metastoreClientConfig, metastore, makeFileName(tempDir, config));
Expand Down

0 comments on commit 5a7e325

Please sign in to comment.