zhaoyongjie commented on code in PR #21449:
URL: https://github.com/apache/superset/pull/21449#discussion_r969706884


##########
superset-frontend/packages/superset-ui-chart-controls/src/operators/utils/getAxis.ts:
##########
@@ -0,0 +1,35 @@
+/**
+ * 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 {
+  DTTM_ALIAS,
+  getColumnLabel,
+  isDefined,
+  QueryFormData,
+} from '@superset-ui/core';
+
+export const getAxis = (formData: QueryFormData): string | undefined => {
+  // The formData should be "raw form_data" -- the snake_case version of 
formData rather than camelCase.
+  if (!(formData.granularity_sqla || formData.x_axis)) {
+    return undefined;
+  }
+
+  return isDefined(formData.x_axis)
+    ? getColumnLabel(formData.x_axis)
+    : DTTM_ALIAS;
+};

Review Comment:
   This function returns a label of a column(the _label_ of the columns, or 
_alias clause_ for the SQL), so the return value might be a string rather than 
a structure data(QueryFormColumn).
   
   another issue is that whether the return value is a `string` or a `string 
array`. both work for me, but the `string array` return value might not 
directly apply to the `post processing` function. I promise that if we will 
support the multiple axes, I am going to refactor this.
   
   The `undefined` value represents a form_data that cannot apply a query with 
an axis. For example, if a `form_data` had `granularity_sqla` neither nor 
`axis`, this function would return an `undefined` value, then the caller should 
easily skip some logic.
   



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