Skip to content

Commit

Permalink
[apache#3129] fix(spark-connector): fix create table failed for using…
Browse files Browse the repository at this point in the history
… hive (apache#3169)

### What changes were proposed in this pull request?
transform `hive` provider to `text` format

### Why are the changes needed?
Fix: apache#3129 

### Does this PR introduce _any_ user-facing change?
no

### How was this patch tested?
add UT and IT
  • Loading branch information
FANNG1 authored Apr 24, 2024
1 parent 503c144 commit 299e666
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,30 @@ void testHiveFormatWithLocationTable() {
});
}

@Test
void testHiveFormatWithUsingHive() {
String tableName = "test_hive_format_using_hive_table";
dropTableIfExists(tableName);
String createTableSql = getCreateSimpleTableString(tableName);
createTableSql += "USING HIVE";
sql(createTableSql);
SparkTableInfo tableInfo = getTableInfo(tableName);

SparkTableInfoChecker checker =
SparkTableInfoChecker.create()
.withName(tableName)
.withTableProperties(
ImmutableMap.of(
HivePropertiesConstants.SPARK_HIVE_INPUT_FORMAT,
HivePropertiesConstants.TEXT_INPUT_FORMAT_CLASS,
HivePropertiesConstants.SPARK_HIVE_OUTPUT_FORMAT,
HivePropertiesConstants.IGNORE_KEY_OUTPUT_FORMAT_CLASS,
HivePropertiesConstants.SPARK_HIVE_SERDE_LIB,
HivePropertiesConstants.LAZY_SIMPLE_SERDE_CLASS));
checker.check(tableInfo);
checkTableReadWrite(tableInfo);
}

@Test
void testHiveFormatWithUsing() {
String tableName = "test_hive_format_using_table";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class HivePropertiesConverter implements PropertiesConverter {
"orc", HivePropertiesConstants.GRAVITINO_HIVE_FORMAT_ORC,
"parquet", HivePropertiesConstants.GRAVITINO_HIVE_FORMAT_PARQUET,
"textfile", HivePropertiesConstants.GRAVITINO_HIVE_FORMAT_TEXTFILE,
"hive", HivePropertiesConstants.GRAVITINO_HIVE_FORMAT_TEXTFILE,
"json", HivePropertiesConstants.GRAVITINO_HIVE_FORMAT_JSON,
"csv", HivePropertiesConstants.GRAVITINO_HIVE_FORMAT_CSV,
"avro", HivePropertiesConstants.GRAVITINO_HIVE_FORMAT_AVRO);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ void testTableFormat() {
ImmutableMap.of(TableCatalog.PROP_PROVIDER, "PARQUET"));
Assertions.assertEquals(
hiveProperties.get(HivePropertiesConstants.GRAVITINO_HIVE_FORMAT), "PARQUET");
hiveProperties =
hivePropertiesConverter.toGravitinoTableProperties(
ImmutableMap.of(TableCatalog.PROP_PROVIDER, "HIVE"));
Assertions.assertEquals(
hiveProperties.get(HivePropertiesConstants.GRAVITINO_HIVE_FORMAT),
HivePropertiesConstants.GRAVITINO_HIVE_FORMAT_TEXTFILE);
Assertions.assertThrowsExactly(
NotSupportedException.class,
() ->
Expand Down

0 comments on commit 299e666

Please sign in to comment.