EnxDev commented on code in PR #43453:
URL: https://github.com/apache/superset/pull/43453#discussion_r3850727029
##########
superset-frontend/src/components/Datasource/components/DatasourceEditor/DatasourceEditor.tsx:
##########
@@ -779,6 +780,43 @@ function EditorsSelector({
const ResultTable =
extensionsRegistry.get('sqleditor.extension.resultTable') ?? FilterableTable;
+// D3's '%' type is a valid spec that multiplies by 100, so it never trips
+// the "Invalid format" fallback even when applied to a raw count. Parsing
+// via the same registry the chart uses excludes garbage like "foo%" that
+// merely ends in '%' without being a valid D3 spec.
+export const isPercentD3Format = (d3format?: string): boolean => {
+ const trimmed = d3format?.trim();
+ return (
+ !!trimmed && trimmed.endsWith('%') &&
!getNumberFormatter(trimmed).isInvalid
+ );
+};
+
+// Anchored to the whole expression so a ratio like `COUNT(*) / COUNT(*)`
+// isn't misclassified as a raw count just because it starts with COUNT(.
+export const isCountExpression = (expression?: string): boolean =>
+ !!expression && /^count\([^()]*\)$/i.test(expression.trim());
Review Comment:
Not intentional, and cheap to fix, so I did: isCountExpression now walks
paren depth instead of forbidding all inner parens, so nested calls are
recognized as a count while ratios like COUNT(*) / COUNT(*) are still correctly
excluded.
[DatasourceEditor.tsx:848](vscode-webview://03msa8759m0ieil9fgknfejjnv98udeg1o5qi9olm6r74uil1bk4/superset-frontend/src/components/Datasource/components/DatasourceEditor/DatasourceEditor.tsx#L848)
--
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]