jackye1995 commented on code in PR #7300:
URL: https://github.com/apache/iceberg/pull/7300#discussion_r1161869535
##########
spark/v3.3/spark/src/test/java/org/apache/iceberg/spark/sql/TestCreateTable.java:
##########
@@ -341,4 +414,65 @@ public void
testDowngradeTableToFormatV1ThroughTablePropertyFails() {
"Cannot downgrade v2 table to v1",
() -> sql("ALTER TABLE %s SET TBLPROPERTIES ('format-version'='1')",
tableName));
}
+
+ private void validateExpectedShowCreateTable(
+ String tableName,
+ String expectedSchema,
+ String expectedLocation,
+ Map<String, String> expectedProperties) {
+ validateExpectedShowCreateTable(
+ tableName, expectedSchema, expectedLocation, expectedProperties, null,
null, null);
+ }
+
+ private void validateExpectedShowCreateTable(
+ String tableName,
+ String expectedSchema,
+ String expectedLocation,
+ Map<String, String> expectedProperties,
+ String comment) {
+ validateExpectedShowCreateTable(
+ tableName, expectedSchema, expectedLocation, expectedProperties, null,
null, comment);
+ }
+
+ private void validateExpectedShowCreateTable(
+ String tableName,
+ String expectedSchema,
+ String expectedLocation,
+ Map<String, String> expectedProperties,
+ String partitionClause,
+ String bucketClause,
+ String comment) {
+ StringBuilder expectedCreate = new StringBuilder();
+
+ expectedCreate.append(
+ String.format(
+ "CREATE TABLE %s ",
+ (catalogName.equals("spark_catalog") ? "spark_catalog." : "") +
tableName));
+
+ expectedCreate.append(expectedSchema + "\n");
+ expectedCreate.append("USING iceberg\n");
+ if (comment != null) {
+ expectedCreate.append(comment + "\n");
+ }
+
+ if (partitionClause != null) {
+ expectedCreate.append(partitionClause + "\n");
+ }
+
+ if (bucketClause != null) {
+ expectedCreate.append(bucketClause + "\n");
+ }
+
+ expectedCreate.append(String.format("LOCATION '%s'\n", expectedLocation));
+ expectedCreate.append("TBLPROPERTIES (\n ");
+ expectedCreate.append(tablePropsAsString(expectedProperties, " = ", ",\n
"));
+ expectedCreate.append(")\n");
+
+ List<Object[]> actualCreate = sql("SHOW CREATE table %s", tableName);
+
+ assertEquals(
+ "Should have expected create",
+ ImmutableList.of(row(expectedCreate.toString())),
+ actualCreate);
Review Comment:
> It looks like table equality isn't formally defined yet
yes I think that's the current status. Maybe we can take this chance to add
definition of table equality?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]