Copilot commented on code in PR #14917:
URL: https://github.com/apache/gravitino/pull/14917#discussion_r4546252157


##########
web-v2/web/src/app/catalogs/rightContent/CreateTableDialog.js:
##########
@@ -76,6 +76,53 @@ import { useAppDispatch } from '@/lib/hooks/useStore'
 const { Paragraph } = Typography
 const { TextArea } = Input
 
+const normalizeColumnDefaultValue = expression => {
+  if (!expression || typeof expression !== 'object') return expression
+
+  switch (expression.type) {
+    case 'literal':
+      return {
+        type: 'literal',
+        dataType: expression.dataType || 'string',
+        value: expression.value
+      }
+
+    case 'field': {
+      const fieldName = expression.fieldName
+
+      return {
+        type: 'field',
+        fieldName: Array.isArray(fieldName) ? fieldName : [fieldName]
+      }
+    }
+
+    case 'function': {
+      const functionArgs = expression.functionArgs || expression.funcArgs || []
+
+      return {
+        type: 'function',
+        functionName: expression.functionName || expression.funcName,
+        functionArgs: functionArgs.map(normalizeColumnDefaultValue)

Review Comment:
   The REST expression format requires `funcName` and `funcArgs` 
(`JsonUtils.readFunctionArg`), but normalization replaces them with 
`functionName` and `functionArgs`. An existing default such as 
`current_timestamp()` therefore differs from the cached value even when 
untouched, causing `genUpdates` to send an invalid `updateColumnDefaultValue` 
request and reject otherwise unrelated table edits. Keep the REST property 
names in the normalized output, including nested function arguments.



##########
web-v2/web/src/app/catalogs/rightContent/entitiesContent/TableDetailsPage.js:
##########
@@ -603,10 +696,33 @@ export default function TableDetailsPage({ ...props }) {
       <Tabs data-refer='details-tabs' defaultActiveKey={tabKey} 
onChange={onChangeTab} items={tabOptions} />
       {tabKey === 'Columns' && (
         <>
-          <Flex justify='flex-end' className='mb-4'>
+          <Flex justify='flex-end' align='center' gap='middle' 
className='mb-4'>
             <div className='flex w-1/3 gap-4'>
               <Search name='searcColumnInput' placeholder='Search...' 
value={search} onChange={onSearchTable} />
             </div>
+
+            <Popover
+              trigger='click'
+              placement='bottomRight'
+              title='Column settings'
+              content={
+                <Checkbox.Group
+                  className='flex flex-col gap-2'
+                  options={[
+                    { label: 'Nullable', value: 'nullable' },
+                    { label: 'AutoIncrement', value: 'autoIncrement' },
+                    { label: 'Default Value', value: 'defaultValue' },
+                    { label: 'Comment', value: 'comment' }
+                  ]}
+                  value={visibleMetadataColumns}
+                  onChange={setVisibleMetadataColumns}
+                />
+              }
+            >
+              <span className='cursor-pointer hover:text-defaultPrimary' 
title='Column settings'>
+                <Icons.Settings className='size-4' />
+              </span>

Review Comment:
   The Column Settings trigger is a non-focusable span and the popover opens 
only on click. Keyboard-only users cannot reach or activate it, so they cannot 
change metadata visibility. Use a native button with an accessible label so 
Tab, Enter, and Space work without custom keyboard handlers.



##########
web-v2/web/src/app/catalogs/rightContent/CreateTableDialog.js:
##########
@@ -963,7 +978,6 @@ export default function CreateTableDialog({ ...props }) {
                       <Switch
                         size='small'
                         disabled={
-                          !!editTable ||
                           
!ColumnTypeSupportAutoIncrement.includes(values?.columns[subField.name]?.typeObj?.type)

Review Comment:
   Removing the edit-mode restriction still leaves AutoIncrement disabled for 
loaded integer columns: the edit initializer stores types using 
`capitalizeFirstLetter` (for example, `Long`), while 
`ColumnTypeSupportAutoIncrement` contains lowercase values such as `long`. 
Users cannot toggle an existing column's AutoIncrement without first 
reselecting its data type. Normalize the form type to lowercase before checking 
support.



##########
web-v2/web/src/lib/utils/index.js:
##########
@@ -186,6 +186,13 @@ export const genUpdates = (originalData, newData, 
disableUpdate = false) => {
           nullable: newColumnsMap[key].nullable
         })
       }
+      if (Boolean(originalColumnsMap[key].autoIncrement) !== 
Boolean(newColumnsMap[key].autoIncrement)) {

Review Comment:
   Removing the edit-dialog restriction also enables AutoIncrement for newly 
added columns, but the earlier `addColumn` payload omits `autoIncrement`. The 
server defaults the missing flag to false, silently losing the selection; this 
new update branch only handles existing columns. Add `autoIncrement: 
Boolean(newColumn.autoIncrement)` to the `addColumn` payload and add a test for 
that case.



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

Reply via email to