Skip to content

Commit

Permalink
[#3772] fix(spark-connector): Iceberg will use upper table to access …
Browse files Browse the repository at this point in the history
…gravitino server sometimes #3772 (#3774)

### What changes were proposed in this pull request?
table name is upper for using `%S`

### Why are the changes needed?

Fix: #3772 

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

### How was this patch tested?
existing tests
  • Loading branch information
FANNG1 authored Jun 5, 2024
1 parent 26be339 commit 26b5cb6
Showing 1 changed file with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -420,12 +420,12 @@ void testAlterTableAddAndDeleteColumn() {
createSimpleTable(tableName);
checkTableColumns(tableName, simpleTableColumns, getTableInfo(tableName));

sql(String.format("ALTER TABLE %S ADD COLUMNS (col1 string)", tableName));
sql(String.format("ALTER TABLE %s ADD COLUMNS (col1 string)", tableName));
ArrayList<SparkColumnInfo> addColumns = new ArrayList<>(simpleTableColumns);
addColumns.add(SparkColumnInfo.of("col1", DataTypes.StringType, null));
checkTableColumns(tableName, addColumns, getTableInfo(tableName));

sql(String.format("ALTER TABLE %S DROP COLUMNS (col1)", tableName));
sql(String.format("ALTER TABLE %s DROP COLUMNS (col1)", tableName));
checkTableColumns(tableName, simpleTableColumns, getTableInfo(tableName));
}

Expand All @@ -439,8 +439,8 @@ void testAlterTableUpdateColumnType() {
createSimpleTable(tableName);
checkTableColumns(tableName, simpleTableColumns, getTableInfo(tableName));

sql(String.format("ALTER TABLE %S ADD COLUMNS (col1 int)", tableName));
sql(String.format("ALTER TABLE %S CHANGE COLUMN col1 col1 bigint", tableName));
sql(String.format("ALTER TABLE %s ADD COLUMNS (col1 int)", tableName));
sql(String.format("ALTER TABLE %s CHANGE COLUMN col1 col1 bigint", tableName));
ArrayList<SparkColumnInfo> updateColumns = new ArrayList<>(simpleTableColumns);
updateColumns.add(SparkColumnInfo.of("col1", DataTypes.LongType, null));
checkTableColumns(tableName, updateColumns, getTableInfo(tableName));
Expand All @@ -457,7 +457,7 @@ void testAlterTableRenameColumn() {
String oldColumnName = "col1";
String newColumnName = "col2";

sql(String.format("ALTER TABLE %S ADD COLUMNS (col1 int)", tableName));
sql(String.format("ALTER TABLE %s ADD COLUMNS (col1 int)", tableName));
sql(
String.format(
"ALTER TABLE %s RENAME COLUMN %s TO %s", tableName, oldColumnName, newColumnName));
Expand All @@ -483,25 +483,25 @@ void testUpdateColumnPosition() {
tableName));
checkTableColumns(tableName, simpleTableColumns, getTableInfo(tableName));

sql(String.format("ALTER TABLE %S ADD COLUMNS (col1 STRING COMMENT '')", tableName));
sql(String.format("ALTER TABLE %s ADD COLUMNS (col1 STRING COMMENT '')", tableName));
List<SparkColumnInfo> updateColumnPositionCol1 = new ArrayList<>(simpleTableColumns);
updateColumnPositionCol1.add(SparkColumnInfo.of("col1", DataTypes.StringType, ""));
checkTableColumns(tableName, updateColumnPositionCol1, getTableInfo(tableName));

sql(String.format("ALTER TABLE %S CHANGE COLUMN col1 col1 STRING FIRST", tableName));
sql(String.format("ALTER TABLE %s CHANGE COLUMN col1 col1 STRING FIRST", tableName));
List<SparkColumnInfo> updateColumnPositionFirst = new ArrayList<>();
updateColumnPositionFirst.add(SparkColumnInfo.of("col1", DataTypes.StringType, ""));
updateColumnPositionFirst.addAll(simpleTableColumns);
checkTableColumns(tableName, updateColumnPositionFirst, getTableInfo(tableName));

sql(String.format("ALTER TABLE %S ADD COLUMNS (col2 STRING COMMENT '')", tableName));
sql(String.format("ALTER TABLE %s ADD COLUMNS (col2 STRING COMMENT '')", tableName));
List<SparkColumnInfo> updateColumnPositionCol2 = new ArrayList<>();
updateColumnPositionCol2.add(SparkColumnInfo.of("col1", DataTypes.StringType, ""));
updateColumnPositionCol2.addAll(simpleTableColumns);
updateColumnPositionCol2.add(SparkColumnInfo.of("col2", DataTypes.StringType, ""));
checkTableColumns(tableName, updateColumnPositionCol2, getTableInfo(tableName));

sql(String.format("ALTER TABLE %S CHANGE COLUMN col2 col2 STRING AFTER col1", tableName));
sql(String.format("ALTER TABLE %s CHANGE COLUMN col2 col2 STRING AFTER col1", tableName));
List<SparkColumnInfo> updateColumnPositionAfter = new ArrayList<>();
updateColumnPositionAfter.add(SparkColumnInfo.of("col1", DataTypes.StringType, ""));
updateColumnPositionAfter.add(SparkColumnInfo.of("col2", DataTypes.StringType, ""));
Expand All @@ -522,10 +522,10 @@ void testAlterTableUpdateColumnComment() {

sql(
String.format(
"ALTER TABLE %S ADD COLUMNS (col1 int comment '%s')", tableName, oldColumnComment));
"ALTER TABLE %s ADD COLUMNS (col1 int comment '%s')", tableName, oldColumnComment));
sql(
String.format(
"ALTER TABLE %S CHANGE COLUMN col1 col1 int comment '%s'",
"ALTER TABLE %s CHANGE COLUMN col1 col1 int comment '%s'",
tableName, newColumnComment));
ArrayList<SparkColumnInfo> updateCommentColumns = new ArrayList<>(simpleTableColumns);
updateCommentColumns.add(SparkColumnInfo.of("col1", DataTypes.IntegerType, newColumnComment));
Expand Down

0 comments on commit 26b5cb6

Please sign in to comment.