This is an automated email from the ASF dual-hosted git repository.

vogievetsky pushed a commit to branch sod
in repository https://gitbox.apache.org/repos/asf/druid.git

commit 6ea58e8b72c6f95faf71890c5e837fb544dee635
Author: Vadim Ogievetsky <[email protected]>
AuthorDate: Tue Apr 30 11:42:53 2024 -0700

    Step
---
 .../explore-view/modules/table-react-module.tsx    | 37 ++++++++++++++--------
 1 file changed, 23 insertions(+), 14 deletions(-)

diff --git a/web-console/src/views/explore-view/modules/table-react-module.tsx 
b/web-console/src/views/explore-view/modules/table-react-module.tsx
index 9880d58dccd..d2ad302fcd2 100644
--- a/web-console/src/views/explore-view/modules/table-react-module.tsx
+++ b/web-console/src/views/explore-view/modules/table-react-module.tsx
@@ -16,6 +16,7 @@
  * limitations under the License.
  */
 
+import { Button } from '@blueprintjs/core';
 import type { SqlOrderByExpression } from '@druid-toolkit/query';
 import {
   C,
@@ -200,13 +201,14 @@ export default typedVisualModule({
 
     compares: {
       type: 'options',
-      options: ['PT1M', 'PT5M', 'PT1H', 'P1D', 'P1M'],
+      options: ['PT1M', 'PT5M', 'PT1H', 'PT6H', 'P1D', 'P1M'],
       control: {
         label: 'Compares',
         optionLabels: {
           PT1M: '1 minute',
           PT5M: '5 minutes',
           PT1H: '1 hour',
+          PT6H: '6 hours',
           P1D: '1 day',
           P1M: '1 month',
         },
@@ -301,6 +303,9 @@ function TableModule(props: TableModuleProps) {
     const pivotValues = pivotColumn ? pivotValueState.data : undefined;
     if (pivotColumn && !pivotValues) return;
 
+    const effectiveOrderBy =
+      orderBy || C(metrics[0]?.name || 
splitColumns[0]?.name).toOrderByExpression('DESC');
+
     const hasCompare = Boolean(compares.length);
 
     const mainQuery = getInitQuery(table, where)
@@ -329,9 +334,7 @@ function TableModule(props: TableModuleProps) {
         ),
       )
       .applyIf(metrics.length > 0 || splitColumns.length > 0, q =>
-        q.changeOrderByExpression(
-          orderBy || C(metrics[0]?.name || 
splitColumns[0]?.name).toOrderByExpression('DESC'),
-        ),
+        q.changeOrderByExpression(effectiveOrderBy),
       )
       .changeLimitValue(maxRows);
 
@@ -376,21 +379,22 @@ function TableModule(props: TableModuleProps) {
             .concat(
               showColumns.map(showColumn => 
main.column(showColumn.name).as(showColumn.name)),
               metrics.map(metric => main.column(metric.name).as(metric.name)),
-              compares.flatMap((_, i) =>
+              compares.flatMap((compare, i) =>
                 metrics.flatMap(metric => {
                   const c = T(`compare${i}`).column(metric.name);
 
-                  const ret = [SqlFunction.simple('COALESCE', [c, 
0]).as(`#prev: ${metric.name}`)];
+                  const ret = [
+                    SqlFunction.simple('COALESCE', [c, 0]).as(
+                      `cmp:${compare}:value:${metric.name}`,
+                    ),
+                  ];
 
                   if (showDelta) {
                     ret.push(
-                      F.stringFormat(
-                        '%.1f%%',
-                        SqlFunction.simple('SAFE_DIVIDE', [
-                          SqlExpression.parse(`(${main.column(metric.name)} - 
${c}) * 100.0`),
-                          c,
-                        ]),
-                      ).as(`%chg: ${metric.name}`),
+                      SqlFunction.simple('SAFE_DIVIDE', [
+                        SqlExpression.parse(`(${main.column(metric.name)} - 
${c}) * 1.0`),
+                        c,
+                      ]).as(`cmp:${compare}:percent:${metric.name}`),
                     );
                   }
 
@@ -440,7 +444,12 @@ function TableModule(props: TableModuleProps) {
   return (
     <div className="table-module">
       {resultState.error ? (
-        resultState.getErrorMessage()
+        <div>
+          <div>{resultState.getErrorMessage()}</div>
+          {resultState.getErrorMessage()?.includes('not found in any table') 
&& orderBy && (
+            <Button text="Clear order by" onClick={() => 
setOrderBy(undefined)} />
+          )}
+        </div>
       ) : resultData ? (
         <GenericOutputTable
           runeMode={false}


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to