zeroshade commented on code in PR #1521:
URL: https://github.com/apache/iceberg-go/pull/1521#discussion_r3647330805


##########
catalog/glue/glue.go:
##########
@@ -970,7 +977,7 @@ func constructTableInput(tableName string, staged 
*table.Table, previousGlueTabl
                },
        }
 
-       if comment, ok := staged.Properties()[PropsKeyDescription]; ok {
+       if comment, ok := descriptionProperty(staged.Properties()); ok {

Review Comment:
   This writes the description to `TableInput.Description`; ensure the same 
value is not also retained in table parameters (see the `constructParameters` 
note).



##########
catalog/glue/glue_test.go:
##########
@@ -280,6 +280,61 @@ func 
TestGlueConstructParametersPreservesReservedParameters(t *testing.T) {
        assert.Equal("value", params["custom"])
 }
 
+func TestGlueConstructDescriptionCompatibility(t *testing.T) {
+       tests := []struct {
+               name     string
+               props    iceberg.Properties
+               expected string
+       }{
+               {
+                       name:     "canonical comment",
+                       props:    iceberg.Properties{PropsKeyDescription: 
"canonical"},
+                       expected: "canonical",
+               },
+               {
+                       name:     "legacy description",
+                       props:    iceberg.Properties{legacyPropsKeyDescription: 
"legacy"},
+                       expected: "legacy",
+               },
+               {
+                       name: "canonical comment wins",
+                       props: iceberg.Properties{
+                               PropsKeyDescription:       "canonical",
+                               legacyPropsKeyDescription: "legacy",
+                       },
+                       expected: "canonical",
+               },
+       }
+
+       for _, tt := range tests {
+               t.Run(tt.name, func(t *testing.T) {
+                       databaseInput := 
constructDatabaseInput("test_namespace", tt.props)
+                       require.Equal(t, tt.expected, 
aws.ToString(databaseInput.Description))
+                       require.NotContains(t, databaseInput.Parameters, 
PropsKeyDescription)
+                       require.NotContains(t, databaseInput.Parameters, 
legacyPropsKeyDescription)
+
+                       metadata, err := table.NewMetadata(
+                               testSchema,
+                               iceberg.UnpartitionedSpec,
+                               table.UnsortedSortOrder,
+                               "s3://test-bucket/test_table",
+                               tt.props,
+                       )
+                       require.NoError(t, err)
+                       staged := table.New(
+                               TableIdentifier("test_database", "test_table"),
+                               metadata,
+                               
"s3://test-bucket/test_table/metadata/v1.metadata.json",
+                               nil,
+                               nil,
+                       )
+
+                       tableInput := constructTableInput("test_table", staged, 
nil)

Review Comment:
   Add assertions (like the DB tests) that table parameters omit 
`comment`/`Description`, to lock in a single source of truth.



-- 
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]

Reply via email to