bito-code-review[bot] commented on code in PR #34859:
URL: https://github.com/apache/superset/pull/34859#discussion_r2329542611


##########
superset-frontend/plugins/legacy-preset-chart-deckgl/src/layers/Polygon/transformProps.ts:
##########
@@ -0,0 +1,143 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import { ChartProps } from '@superset-ui/core';
+import { addJsColumnsToExtraProps, DataRecord } from '../spatialUtils';
+import {
+  createBaseTransformResult,
+  getRecordsFromQuery,
+  getMetricLabelFromFormData,
+  parseMetricValue,
+  addPropertiesToFeature,
+} from '../transformUtils';
+import { DeckPolygonFormData } from './buildQuery';
+
+interface PolygonFeature {
+  polygon?: number[][];
+  name?: string;
+  elevation?: number;
+  extraProps: Record<string, unknown>;

Review Comment:
   
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Interface breaking change</b></div>
   <div id="fix">
   
   The PolygonFeature interface change from optional `extraProps?: 
Record<string, unknown>` to required `extraProps: Record<string, unknown>` 
breaks backward compatibility. Downstream components expect this to be 
optional, and the existing codebase initializes features with empty objects 
anyway. This change will cause TypeScript compilation errors in consuming 
components.
   </div>
   <details>
   <summary>
   <b>Code suggestion</b>
   </summary>
   <blockquote>Check the AI-generated fix before applying</blockquote>
   <div id="code">
   
   
   ```suggestion
     extraProps?: Record<string, unknown>;
   ```
   
   </div>
   </details>
   </div>
   
   
   
   <small><i>Code Review Run <a 
href=https://github.com/apache/superset/pull/34859#issuecomment-3265150195>#ab6674</a></i></small>
   </div>
   
   ---
   Should Bito avoid suggestions like this for future reviews? (<a 
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
   - [ ] Yes, avoid them



##########
superset-frontend/plugins/legacy-preset-chart-deckgl/src/layers/Scatter/buildQuery.ts:
##########
@@ -0,0 +1,86 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import {
+  buildQueryContext,
+  ensureIsArray,
+  SqlaFormData,
+} from '@superset-ui/core';
+import {
+  getSpatialColumns,
+  addSpatialNullFilters,
+  SpatialFormData,
+} from '../spatialUtils';
+import { addJsColumnsToColumns, processMetricsArray } from 
'../buildQueryUtils';
+
+export interface DeckScatterFormData
+  extends Omit<SpatialFormData, 'color_picker'>,
+    SqlaFormData {
+  point_radius_fixed?: {
+    value?: string;
+  };
+  multiplier?: number;
+  point_unit?: string;
+  min_radius?: number;
+  max_radius?: number;
+  color_picker?: { r: number; g: number; b: number; a: number };
+  category_name?: string;
+}
+
+export default function buildQuery(formData: DeckScatterFormData) {
+  const { spatial, point_radius_fixed, category_name, js_columns } = formData;
+
+  if (!spatial) {
+    throw new Error('Spatial configuration is required for Scatter charts');
+  }
+
+  return buildQueryContext(formData, {
+    buildQuery: baseQueryObject => {
+      const spatialColumns = getSpatialColumns(spatial);
+      let columns = [...(baseQueryObject.columns || []), ...spatialColumns];
+
+      if (category_name) {
+        columns.push(category_name);
+      }
+
+      columns = addJsColumnsToColumns(columns.map(String), js_columns);
+
+      const metrics = processMetricsArray([point_radius_fixed?.value]);
+      const filters = addSpatialNullFilters(
+        spatial,
+        ensureIsArray(baseQueryObject.filters || []),
+      );
+
+      const orderby = point_radius_fixed?.value
+        ? [[point_radius_fixed.value, false] as [string, boolean]]
+        : baseQueryObject.orderby || [];

Review Comment:
   
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Type assertion incompatible</b></div>
   <div id="fix">
   
   The type assertion `as [string, boolean]` is incompatible with the 
`QueryFormOrderBy` type which expects `[QueryFormColumn | QueryFormMetric | {}, 
boolean] | []`. This incorrect type casting could lead to runtime type errors 
when the orderby parameter is processed by downstream consumers like 
`buildQueryContext`. Remove the type assertion to let TypeScript properly infer 
the correct type.
   </div>
   <details>
   <summary>
   <b>Code suggestion</b>
   </summary>
   <blockquote>Check the AI-generated fix before applying</blockquote>
   <div id="code">
   
   
   ```suggestion
         const orderby = point_radius_fixed?.value
           ? [[point_radius_fixed.value, false]]
           : baseQueryObject.orderby || [];
   ```
   
   </div>
   </details>
   </div>
   
   
   
   <small><i>Code Review Run <a 
href=https://github.com/apache/superset/pull/34859#issuecomment-3265150195>#ab6674</a></i></small>
   </div>
   
   ---
   Should Bito avoid suggestions like this for future reviews? (<a 
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
   - [ ] Yes, avoid them



##########
superset-frontend/plugins/legacy-preset-chart-deckgl/src/layers/Path/buildQuery.ts:
##########
@@ -0,0 +1,85 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import {
+  buildQueryContext,
+  ensureIsArray,
+  SqlaFormData,
+} from '@superset-ui/core';
+import { addNullFilters } from '../buildQueryUtils';
+
+export interface DeckPathFormData extends SqlaFormData {
+  line_column?: string;
+  line_type?: 'polyline' | 'json' | 'geohash';
+  metric?: string;
+  reverse_long_lat?: boolean;
+  js_columns?: string[];
+}
+
+export default function buildQuery(formData: DeckPathFormData) {
+  const { line_column, metric, js_columns } = formData;
+
+  if (!line_column) {
+    throw new Error('Line column is required for Path charts');
+  }
+
+  return buildQueryContext(formData, {
+    buildQuery: baseQueryObject => {
+      const columns = ensureIsArray(baseQueryObject.columns || []);
+      const metrics = ensureIsArray(baseQueryObject.metrics || []);
+      const groupby = ensureIsArray(baseQueryObject.groupby || []);
+      const jsColumns = ensureIsArray(js_columns || []);
+
+      if (baseQueryObject.metrics?.length || metric) {
+        if (metric && !metrics.includes(metric)) {
+          metrics.push(metric);
+        }
+        if (!groupby.includes(line_column)) {
+          groupby.push(line_column);
+        }
+      } else if (!columns.includes(line_column)) {
+        columns.push(line_column);
+      }
+
+      jsColumns.forEach(col => {
+        if (!columns.includes(col) && !groupby.includes(col)) {
+          columns.push(col);
+        }
+      });
+
+      const filters = addNullFilters(
+        ensureIsArray(baseQueryObject.filters || []),
+        [line_column],

Review Comment:
   
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Incomplete filter handling</b></div>
   <div id="fix">
   
   The refactoring is missing NOT NULL filters for js_columns. The original 
implementation manually checked and added NOT NULL filters for both line_column 
and js_columns, but the new addNullFilters call only includes line_column. This 
could lead to rendering issues when js_columns contain null values. Update the 
addNullFilters call to include [line_column, ...jsColumns] to maintain 
consistency with the original logic.
   </div>
   <details>
   <summary>
   <b>Code suggestion</b>
   </summary>
   <blockquote>Check the AI-generated fix before applying</blockquote>
   <div id="code">
   
   
   ```suggestion
         const filters = addNullFilters(
           ensureIsArray(baseQueryObject.filters || []),
           [line_column, ...jsColumns],
   ```
   
   </div>
   </details>
   </div>
   
   
   
   <small><i>Code Review Run <a 
href=https://github.com/apache/superset/pull/34859#issuecomment-3265150195>#ab6674</a></i></small>
   </div>
   
   ---
   Should Bito avoid suggestions like this for future reviews? (<a 
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
   - [ ] Yes, avoid them



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