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


##########
web-v2/web/src/app/catalogs/rightContent/CreateTableDialog.js:
##########
@@ -115,10 +115,18 @@ export default function CreateTableDialog({ ...props }) {
   const [form] = Form.useForm()
   const values = Form.useWatch([], form)
 
+  const isClickHouseDistributedEngine =
+    provider === 'jdbc-clickhouse' &&
+    (values?.engine || values?.properties?.find(item => item?.key === 
'engine')?.value)?.toLowerCase?.() ===
+      'distributed'

Review Comment:
   `isClickHouseDistributedEngine` relies on a strict equality check against 
`'distributed'` but doesn’t trim the user-provided engine value. If the 
property value contains leading/trailing whitespace (e.g., `"Distributed "`), 
the dialog will still treat columns as required and won’t allow creating a 
no-columns distributed table. Normalize the value first (e.g., trim + 
lowercase) before comparing.
   ```suggestion
     const rawEngine =
       values?.engine ??
       values?.properties?.find(item => item?.key === 'engine')?.value
     const normalizedEngine =
       typeof rawEngine === 'string' ? rawEngine.trim().toLowerCase() : 
undefined
     const isClickHouseDistributedEngine =
       provider === 'jdbc-clickhouse' && normalizedEngine === 'distributed'
   ```



##########
web-v2/web/src/app/catalogs/rightContent/CreateTableDialog.js:
##########
@@ -925,16 +967,17 @@ export default function CreateTableDialog({ ...props }) {
                 <div className='px-2 py-1'>
                   <Icons.Minus
                     className={cn('size-4 cursor-pointer text-gray-400 
hover:text-defaultPrimary', {
-                      'text-gray-100 hover:text-gray-200 cursor-not-allowed': 
form.getFieldValue('columns').length === 1
+                      'text-gray-100 hover:text-gray-200 cursor-not-allowed':
+                        form.getFieldValue('columns').length === 1 && 
isColumnsRequired
                     })}
                     onClick={() => {
-                      if (form.getFieldValue('columns').length === 1) return
+                      if (form.getFieldValue('columns').length === 1 && 
isColumnsRequired) return
                       subOpt.remove(subField.name)
                       if (fields.length - 1 === pageOffset * pageSize) {
-                        setPageOffset(pageOffset - 1)
+                        setPageOffset(Math.max(1, pageOffset - 1))
                       } else if (fields.length - 1 < pageOffset * pageSize) {
                         const to = Math.ceil(fields.length / pageSize)
-                        setPageOffset((fields.length - 1) % pageSize === 0 ? 
to - 1 : to)
+                        setPageOffset(Math.max(1, (fields.length - 1) % 
pageSize === 0 ? to - 1 : to))
                       }

Review Comment:
   In the column remove handler, the `fields.length - 1 === pageOffset * 
pageSize` branch always decrements `pageOffset`. This can jump the user back a 
page even when the current page is still valid after removal (e.g., 21 items on 
page 2 → remove one → 20 items, page 2 still exists, but `pageOffset` becomes 
1). Consider recomputing the last page after removal and clamping `pageOffset` 
to that, rather than unconditionally moving back one page in this 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