You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gravitino.apache.org by "LauraXia123 (via GitHub)" <gi...@apache.org> on 2026/08/03 09:59:13 UTC

[PR] [#12337] feat(web): Support ClickHouse data-skipping indexes and engine-aware sort orders validation [gravitino]

LauraXia123 opened a new pull request, #12339:
URL: https://github.com/apache/gravitino/pull/12339

   ### What changes were proposed in this pull request?
   
   This PR enhances the `CreateTableDialog` for ClickHouse table creation with two features:
   
   **1. Support ClickHouse data-skipping index types with properties**
   
   - Add **Granularity** column in the Indexes tab, shown for data-skipping index types (`data_skipping_minmax`, `data_skipping_bloom_filter`, `data_skipping_set`), hidden (`-`) for `primary_key`
   - Add **Set Max Values** column, shown only for `data_skipping_set` index type
   - Populate `granularity` and `set_max_values` when editing an existing table
   - Include index `properties` object in the submit payload for data-skipping indexes
   - Clear granularity/setMaxValues fields when index type changes
   
   **2. Engine-aware sort orders validation**
   
   - Add `clickHouseEngine` and `isClickHouseMergeTreeEngine` computed variables to detect the current engine type in real-time
   - Show required indicator (`*`) on Sort Orders tab only for MergeTree family engines
   - Move sort orders validation from `Form.Item rules` (which can cache stale closure values) to `handleSubmit` where `form.getFieldValue('engine')` reads the current engine value
   - Add `useEffect` on `isClickHouseMergeTreeEngine` to:
     - Clear sort orders data and validation errors when switching to non-MergeTree engines
     - Show required validation error when switching to MergeTree engines with empty sort orders
   - Remove `validateTrigger='onSubmit'` and `rules` from sortOrders `Form.Item` to avoid Ant Design Form caching stale validator closures
   
   ### Why are the changes needed?
   
   1. ClickHouse data-skipping indexes require `granularity` and `set_max_values` properties to be configured. Without these fields in the UI, users cannot properly create data-skipping indexes through the Gravitino web interface.
   
   2. Sort orders are only required for MergeTree family engines. For other ClickHouse engines (Distributed, TinyLog, Log, StripeLog), sort orders are optional. The previous implementation always validated sort orders as required regardless of engine type, causing form submission to fail for non-MergeTree engines when sort orders were empty.
   
   Fix: #12337
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes:
   1. **Indexes tab**: Two new columns (Granularity, Set Max Values) are added for ClickHouse tables. These columns show `-` for non-data-skipping index types.
   2. **Sort Orders tab**: The required indicator (`*`) now dynamically appears/disappears based on the selected ClickHouse engine type. Sort orders are only required for MergeTree family engines.
   3. **Engine switch**: Switching from a MergeTree engine to a non-MergeTree engine now clears sort orders data and validation errors automatically.
   
   ### How was this patch tested?
   
   1. Create a ClickHouse table with MergeTree engine - verify Sort Orders tab shows `*` and validation requires at least one sort order
   2. Switch engine from MergeTree to TinyLog/Log/StripeLog/Distributed - verify `*` disappears, sort orders data is cleared, and form can be submitted without sort orders
   3. Switch engine back to MergeTree - verify `*` reappears and validation error shows if sort orders are empty
   4. Create a table with `data_skipping_minmax` index - verify Granularity field is shown, Set Max Values shows `-`
   5. Create a table with `data_skipping_set` index - verify both Granularity and Set Max Values fields are shown
   6. Create a table with `primary_key` index - verify both Granularity and Set Max Values show `-`
   7. Edit an existing table with data-skipping indexes - verify granularity and set_max_values are populated correctly
   8. Submit a table with data-skipping index properties - verify properties are included in the API payload


-- 
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: commits-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#12337] feat(web): Support ClickHouse data-skipping indexes and engine-aware sort orders validation [gravitino]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #12339:
URL: https://github.com/apache/gravitino/pull/12339#discussion_r3703062336


##########
web-v2/web/src/app/catalogs/rightContent/CreateTableDialog.js:
##########
@@ -594,9 +654,54 @@ export default function CreateTableDialog({ ...props }) {
 
   const handleSubmit = e => {
     e.preventDefault()
+
+    const currentEngine = form.getFieldValue('engine')
+    const isCurrentMergeTree = provider === 'jdbc-clickhouse' && clickHouseMergeTreeEngines.includes(currentEngine)

Review Comment:
   `currentEngine` is read from the `engine` top-level field, but elsewhere in this component ClickHouse engine is also derived from `values?.properties` (key `engine`). If the form stores engine under `properties` (or if `engine` is unset), `isCurrentMergeTree` can be computed incorrectly and MergeTree-required Sort Orders validation may be skipped. Align submit-time engine detection with the same source of truth used for `clickHouseEngine` (or derive it from the actual form structure used for engine).



##########
web-v2/web/src/config/catalog.js:
##########
@@ -223,6 +223,32 @@ export const tableDefaultProps = {
       select: ['lance', 'delta'],
       description: 'The format of the table'
     }
+  ],
+  'jdbc-clickhouse': [
+    {
+      key: 'engine',
+      defaultValue: 'MergeTree',
+      select: [
+        'MergeTree',
+        'ReplacingMergeTree',
+        'SummingMergeTree',
+        'AggregatingMergeTree',
+        'CollapsingMergeTree',
+        'VersionedCollapsingMergeTree',
+        'GraphiteMergeTree',
+        'ReplicatedMergeTree',
+        'ReplicatedReplacingMergeTree',
+        'ReplicatedSummingMergeTree',
+        'ReplicatedAggregatingMergeTree',
+        'ReplicatedCollapsingMergeTree',
+        'ReplicatedVersionedCollapsingMergeTree',
+        'ReplicatedGraphiteMergeTree',
+        'Distributed',
+        'TinyLog',
+        'Log',
+        'StripeLog'
+      ]

Review Comment:
   The MergeTree engine list is duplicated here and in `clickHouseMergeTreeEngines` (web/src/config/index.js). This increases drift risk (e.g., adding/removing an engine in one place but not the other). Consider reusing a single exported constant (e.g., build this `select` as `[...]clickHouseMergeTreeEngines, 'Distributed', 'TinyLog', 'Log', 'StripeLog'`) or moving engine definitions into one shared config module.



##########
web-v2/web/src/app/catalogs/rightContent/CreateTableDialog.js:
##########
@@ -471,6 +521,16 @@ export default function CreateTableDialog({ ...props }) {
                 form.setFieldValue(['indexes', idxIndex, 'name'], item.name)
                 form.setFieldValue(['indexes', idxIndex, 'indexType'], capitalizeFirstLetter(item.indexType))

Review Comment:
   Index type comparisons and payload building rely on `startsWith('data_skipping_')`, but when editing an existing table you set `indexType` using `capitalizeFirstLetter(item.indexType)`. If that transforms `data_skipping_*` into a different casing, the UI will fail to show Granularity/Set Max Values and the submit payload will omit `properties` (and may send an unexpected `indexType` value). Store/compare `indexType` in a canonical format (e.g., keep the backend value as-is / lowercase) and only transform for display/labels if needed; alternatively, normalize comparisons with `.toLowerCase()`.



##########
web-v2/web/src/app/catalogs/rightContent/CreateTableDialog.js:
##########
@@ -118,6 +119,14 @@ export default function CreateTableDialog({ ...props }) {
   const isClickHouseDistributedEngine =
     provider === 'jdbc-clickhouse' &&
     values?.properties?.find(item => item?.key === 'engine')?.value?.toLowerCase?.() === 'distributed'
+
+  const clickHouseEngine =
+    provider === 'jdbc-clickhouse'
+      ? values?.engine || values?.properties?.find(item => item?.key === 'engine')?.value
+      : undefined
+
+  const isClickHouseMergeTreeEngine =
+    provider === 'jdbc-clickhouse' && clickHouseMergeTreeEngines.includes(clickHouseEngine)

Review Comment:
   `clickHouseMergeTreeEngines.includes(clickHouseEngine)` is case-sensitive, but the engine may come from different sources (form field vs. properties) and other checks in this file already normalize with `toLowerCase()`. To avoid inconsistent behavior, normalize the engine value before comparison (e.g., compare in a single consistent case) so the MergeTree detection is robust regardless of value source.



-- 
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: commits-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#12337] feat(web): Support ClickHouse data-skipping indexes and engine-aware sort orders validation [gravitino]

Posted by "LauraXia123 (via GitHub)" <gi...@apache.org>.
LauraXia123 commented on code in PR #12339:
URL: https://github.com/apache/gravitino/pull/12339#discussion_r3725596017


##########
web-v2/web/src/config/catalog.js:
##########
@@ -223,6 +225,41 @@ export const tableDefaultProps = {
       select: ['lance', 'delta'],
       description: 'The format of the table'
     }
+  ],
+  'jdbc-clickhouse': [
+    {
+      key: 'engine',
+      defaultValue: 'MergeTree',
+      selectGroups: clickHouseEngineGroups
+    },
+    {
+      key: 'cluster-name',
+      defaultValue: '',
+      parentField: 'engine',
+      show: ['Distributed'],
+      description: 'The cluster name for DDL operations'
+    },
+    {
+      key: 'cluster-remote-database',
+      defaultValue: '',
+      parentField: 'engine',
+      show: ['Distributed'],
+      description: 'The remote database name for ClickHouse distributed tables'
+    },
+    {
+      key: 'cluster-remote-table',
+      defaultValue: '',
+      parentField: 'engine',
+      show: ['Distributed'],
+      description: 'The remote table name for ClickHouse distributed tables'
+    },
+    {
+      key: 'cluster-sharding-key',
+      defaultValue: '',
+      parentField: 'engine',
+      show: ['Distributed'],
+      description: 'The sharding key for ClickHouse distributed tables'
+    }

Review Comment:
   getActiveTableDefaultProps have handle 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: commits-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#12337] feat(web): Support ClickHouse data-skipping indexes and engine-aware sort orders validation [gravitino]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #12339:
URL: https://github.com/apache/gravitino/pull/12339#discussion_r3719712238


##########
web-v2/web/src/app/catalogs/rightContent/CreateTableDialog.js:
##########
@@ -686,7 +781,7 @@ export default function CreateTableDialog({ ...props }) {
               }
             })
           }
-          if (sortOredsInfo) {
+          if (sortOredsInfo && isSortOrdersRequired) {
             submitData['sortOrders'] = values.sortOrders?.map(s => {

Review Comment:
   The Sort Orders tab and submit payload are currently gated by `isSortOrdersRequired` (MergeTree only). This makes sort orders impossible to create/submit for non-MergeTree engines even if the user provides them, and contradicts the stated behavior that sort orders are optional (not unavailable) for other engines. Consider always rendering the Sort Orders tab when `sortOredsInfo` is supported, always submitting `sortOrders` when present, and only applying the *required* validation when the engine is MergeTree-family.



##########
web-v2/web/src/config/catalog.js:
##########
@@ -223,6 +225,41 @@ export const tableDefaultProps = {
       select: ['lance', 'delta'],
       description: 'The format of the table'
     }
+  ],
+  'jdbc-clickhouse': [
+    {
+      key: 'engine',
+      defaultValue: 'MergeTree',
+      selectGroups: clickHouseEngineGroups
+    },
+    {
+      key: 'cluster-name',
+      defaultValue: '',
+      parentField: 'engine',
+      show: ['Distributed'],
+      description: 'The cluster name for DDL operations'
+    },
+    {
+      key: 'cluster-remote-database',
+      defaultValue: '',
+      parentField: 'engine',
+      show: ['Distributed'],
+      description: 'The remote database name for ClickHouse distributed tables'
+    },
+    {
+      key: 'cluster-remote-table',
+      defaultValue: '',
+      parentField: 'engine',
+      show: ['Distributed'],
+      description: 'The remote table name for ClickHouse distributed tables'
+    },
+    {
+      key: 'cluster-sharding-key',
+      defaultValue: '',
+      parentField: 'engine',
+      show: ['Distributed'],
+      description: 'The sharding key for ClickHouse distributed tables'
+    }

Review Comment:
   The PR description states these four Distributed engine fields are 'required validation', but the diff only adds conditional display metadata; no required validation is introduced for these keys. Add engine-aware required rules (or submit-time checks) when `engine === 'Distributed'`, otherwise users can submit invalid Distributed definitions.



##########
web-v2/web/src/app/catalogs/rightContent/CreateTableDialog.js:
##########
@@ -197,10 +237,17 @@ export default function CreateTableDialog({ ...props }) {
         key: 'partitions'
       })
     }
-    if (sortOredsInfo) {
-      ;``
+    if (sortOredsInfo && isSortOrdersRequired) {
       tabs.push({
-        label: <span className='font-normal text-[rgb(0,0,0,0.88)]'>Sort Orders</span>,
+        label: (
+          <span
+            className={cn('font-normal text-[rgb(0,0,0,0.88)]', {
+              'before:mr-0.5 before:font-["SimSun"] before:text-[#ff4d4f] before:content-["*"]': isSortOrdersRequired
+            })}
+          >
+            Sort Orders
+          </span>
+        ),
         key: 'sortOrders'
       })
     }

Review Comment:
   The Sort Orders tab and submit payload are currently gated by `isSortOrdersRequired` (MergeTree only). This makes sort orders impossible to create/submit for non-MergeTree engines even if the user provides them, and contradicts the stated behavior that sort orders are optional (not unavailable) for other engines. Consider always rendering the Sort Orders tab when `sortOredsInfo` is supported, always submitting `sortOrders` when present, and only applying the *required* validation when the engine is MergeTree-family.



-- 
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: commits-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#12337] feat(web): Support ClickHouse data-skipping indexes and engine-aware sort orders validation [gravitino]

Posted by "LauraXia123 (via GitHub)" <gi...@apache.org>.
LauraXia123 commented on code in PR #12339:
URL: https://github.com/apache/gravitino/pull/12339#discussion_r3725585200


##########
web-v2/web/src/app/catalogs/rightContent/CreateTableDialog.js:
##########
@@ -197,10 +237,17 @@ export default function CreateTableDialog({ ...props }) {
         key: 'partitions'
       })
     }
-    if (sortOredsInfo) {
-      ;``
+    if (sortOredsInfo && isSortOrdersRequired) {
       tabs.push({
-        label: <span className='font-normal text-[rgb(0,0,0,0.88)]'>Sort Orders</span>,
+        label: (
+          <span
+            className={cn('font-normal text-[rgb(0,0,0,0.88)]', {
+              'before:mr-0.5 before:font-["SimSun"] before:text-[#ff4d4f] before:content-["*"]': isSortOrdersRequired
+            })}
+          >
+            Sort Orders
+          </span>
+        ),
         key: 'sortOrders'
       })
     }

Review Comment:
   The sort orders is not unavailable for  non-MergeTree engines



-- 
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: commits-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org