You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by mi...@apache.org on 2023/11/08 12:59:17 UTC
(superset) branch 3.0 updated (5198279a2b -> d265bd2ffc)
This is an automated email from the ASF dual-hosted git repository.
michaelsmolina pushed a change to branch 3.0
in repository https://gitbox.apache.org/repos/asf/superset.git
from 5198279a2b fix: remove `update_charts_owners` (#25843)
new 756324d713 fix(charts): Time grain is None when dataset uses Jinja (#25842)
new 81f7c63763 fix: Saving Mixed Chart with dashboard filter applied breaks adhoc_filter_b (#25877)
new 8c099a3f6f fix: database version field (#25898)
new d265bd2ffc fix: trino cursor (#25897)
The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../src/query/normalizeTimeColumn.ts | 5 +-
.../test/query/normalizeTimeColumn.test.ts | 8 ++--
.../test/MixedTimeseries/buildQuery.test.ts | 1 +
.../test/Timeseries/buildQuery.test.ts | 4 +-
.../src/plugin/buildQuery.ts | 6 +--
.../test/plugin/buildQuery.test.ts | 13 ++++++
.../src/explore/actions/saveModalActions.js | 19 +++++---
.../src/explore/actions/saveModalActions.test.js | 53 ++++++++++++++++++++++
.../databases/DatabaseModal/ExtraOptions.tsx | 6 +--
superset/db_engine_specs/trino.py | 32 +++++++------
10 files changed, 111 insertions(+), 36 deletions(-)
(superset) 04/04: fix: trino cursor (#25897)
Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
michaelsmolina pushed a commit to branch 3.0
in repository https://gitbox.apache.org/repos/asf/superset.git
commit d265bd2ffcaed2bb5f2ba7dd139afeb9c5654645
Author: Beto Dealmeida <ro...@dealmeida.net>
AuthorDate: Wed Nov 8 07:38:38 2023 -0500
fix: trino cursor (#25897)
(cherry picked from commit cdb18e04ffa7d50120a26af990d1ce35b2bd8b5e)
---
superset/db_engine_specs/trino.py | 32 +++++++++++++++++++-------------
1 file changed, 19 insertions(+), 13 deletions(-)
diff --git a/superset/db_engine_specs/trino.py b/superset/db_engine_specs/trino.py
index f758f1fadd..19c11939c4 100644
--- a/superset/db_engine_specs/trino.py
+++ b/superset/db_engine_specs/trino.py
@@ -187,7 +187,7 @@ class TrinoEngineSpec(PrestoBaseEngineSpec):
@classmethod
def execute_with_cursor(
- cls, cursor: Any, sql: str, query: Query, session: Session
+ cls, cursor: Cursor, sql: str, query: Query, session: Session
) -> None:
"""
Trigger execution of a query and handle the resulting cursor.
@@ -196,34 +196,40 @@ class TrinoEngineSpec(PrestoBaseEngineSpec):
in another thread and invoke `handle_cursor` to poll for the query ID
to appear on the cursor in parallel.
"""
+ # Fetch the query ID beforehand, since it might fail inside the thread due to
+ # how the SQLAlchemy session is handled.
+ query_id = query.id
+
execute_result: dict[str, Any] = {}
+ execute_event = threading.Event()
- def _execute(results: dict[str, Any]) -> None:
- logger.debug("Query %d: Running query: %s", query.id, sql)
+ def _execute(results: dict[str, Any], event: threading.Event) -> None:
+ logger.debug("Query %d: Running query: %s", query_id, sql)
- # Pass result / exception information back to the parent thread
try:
cls.execute(cursor, sql)
- results["complete"] = True
except Exception as ex: # pylint: disable=broad-except
- results["complete"] = True
results["error"] = ex
+ finally:
+ event.set()
- execute_thread = threading.Thread(target=_execute, args=(execute_result,))
+ execute_thread = threading.Thread(
+ target=_execute,
+ args=(execute_result, execute_event),
+ )
execute_thread.start()
# Wait for a query ID to be available before handling the cursor, as
# it's required by that method; it may never become available on error.
- while not cursor.query_id and not execute_result.get("complete"):
+ while not cursor.query_id and not execute_event.is_set():
time.sleep(0.1)
- logger.debug("Query %d: Handling cursor", query.id)
+ logger.debug("Query %d: Handling cursor", query_id)
cls.handle_cursor(cursor, query, session)
# Block until the query completes; same behaviour as the client itself
- logger.debug("Query %d: Waiting for query to complete", query.id)
- while not execute_result.get("complete"):
- time.sleep(0.5)
+ logger.debug("Query %d: Waiting for query to complete", query_id)
+ execute_event.wait()
# Unfortunately we'll mangle the stack trace due to the thread, but
# throwing the original exception allows mapping database errors as normal
@@ -237,7 +243,7 @@ class TrinoEngineSpec(PrestoBaseEngineSpec):
session.commit()
@classmethod
- def cancel_query(cls, cursor: Any, query: Query, cancel_query_id: str) -> bool:
+ def cancel_query(cls, cursor: Cursor, query: Query, cancel_query_id: str) -> bool:
"""
Cancel query in the underlying database.
(superset) 02/04: fix: Saving Mixed Chart with dashboard filter applied breaks adhoc_filter_b (#25877)
Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
michaelsmolina pushed a commit to branch 3.0
in repository https://gitbox.apache.org/repos/asf/superset.git
commit 81f7c63763ba7816fa9ba7acbf9675fefe102d61
Author: Kamil Gabryjelski <ka...@gmail.com>
AuthorDate: Mon Nov 6 19:52:27 2023 +0100
fix: Saving Mixed Chart with dashboard filter applied breaks adhoc_filter_b (#25877)
(cherry picked from commit 268c1dcdad60b59498c4fd55155a2bf2e586332e)
---
.../src/explore/actions/saveModalActions.js | 19 +++++---
.../src/explore/actions/saveModalActions.test.js | 53 ++++++++++++++++++++++
2 files changed, 66 insertions(+), 6 deletions(-)
diff --git a/superset-frontend/src/explore/actions/saveModalActions.js b/superset-frontend/src/explore/actions/saveModalActions.js
index 0bf7ced475..53c8952082 100644
--- a/superset-frontend/src/explore/actions/saveModalActions.js
+++ b/superset-frontend/src/explore/actions/saveModalActions.js
@@ -50,7 +50,7 @@ export function saveSliceSuccess(data) {
return { type: SAVE_SLICE_SUCCESS, data };
}
-const extractAddHocFiltersFromFormData = formDataToHandle =>
+const extractAdhocFiltersFromFormData = formDataToHandle =>
Object.entries(formDataToHandle).reduce(
(acc, [key, value]) =>
ADHOC_FILTER_REGEX.test(key)
@@ -71,7 +71,7 @@ export const getSlicePayload = (
owners,
formDataFromSlice = {},
) => {
- const adhocFilters = extractAddHocFiltersFromFormData(
+ const adhocFilters = extractAdhocFiltersFromFormData(
formDataWithNativeFilters,
);
@@ -80,10 +80,17 @@ export const getSlicePayload = (
// to filter the chart. Before, any time range filter applied in the dashboard
// would end up as an extra filter and when overwriting the chart the original
// time range adhoc_filter was lost
- if (isEmpty(adhocFilters?.adhoc_filters) && !isEmpty(formDataFromSlice)) {
- formDataFromSlice?.adhoc_filters?.forEach(filter => {
- if (filter.operator === Operators.TEMPORAL_RANGE && !filter.isExtra) {
- adhocFilters.adhoc_filters.push({ ...filter, comparator: 'No filter' });
+ if (!isEmpty(formDataFromSlice)) {
+ Object.keys(adhocFilters || {}).forEach(adhocFilterKey => {
+ if (isEmpty(adhocFilters[adhocFilterKey])) {
+ formDataFromSlice?.[adhocFilterKey]?.forEach(filter => {
+ if (filter.operator === Operators.TEMPORAL_RANGE && !filter.isExtra) {
+ adhocFilters[adhocFilterKey].push({
+ ...filter,
+ comparator: 'No filter',
+ });
+ }
+ });
}
});
}
diff --git a/superset-frontend/src/explore/actions/saveModalActions.test.js b/superset-frontend/src/explore/actions/saveModalActions.test.js
index 4c0da5132d..fc50e3d3cf 100644
--- a/superset-frontend/src/explore/actions/saveModalActions.test.js
+++ b/superset-frontend/src/explore/actions/saveModalActions.test.js
@@ -391,4 +391,57 @@ describe('getSlicePayload', () => {
formDataFromSlice.adhoc_filters,
);
});
+
+ test('should return the correct payload when formDataWithNativeFilters has a filter with isExtra set to true in mixed chart', () => {
+ const formDataFromSliceWithAdhocFilterB = {
+ ...formDataFromSlice,
+ adhoc_filters_b: [
+ {
+ clause: 'WHERE',
+ subject: 'year',
+ operator: 'TEMPORAL_RANGE',
+ comparator: 'No filter',
+ expressionType: 'SIMPLE',
+ },
+ ],
+ };
+ const formDataWithAdhocFiltersWithExtra = {
+ ...formDataWithNativeFilters,
+ viz_type: 'mixed_timeseries',
+ adhoc_filters: [
+ {
+ clause: 'WHERE',
+ subject: 'year',
+ operator: 'TEMPORAL_RANGE',
+ comparator: 'No filter',
+ expressionType: 'SIMPLE',
+ isExtra: true,
+ },
+ ],
+ adhoc_filters_b: [
+ {
+ clause: 'WHERE',
+ subject: 'year',
+ operator: 'TEMPORAL_RANGE',
+ comparator: 'No filter',
+ expressionType: 'SIMPLE',
+ isExtra: true,
+ },
+ ],
+ };
+ const result = getSlicePayload(
+ sliceName,
+ formDataWithAdhocFiltersWithExtra,
+ dashboards,
+ owners,
+ formDataFromSliceWithAdhocFilterB,
+ );
+
+ expect(JSON.parse(result.params).adhoc_filters).toEqual(
+ formDataFromSliceWithAdhocFilterB.adhoc_filters,
+ );
+ expect(JSON.parse(result.params).adhoc_filters_b).toEqual(
+ formDataFromSliceWithAdhocFilterB.adhoc_filters_b,
+ );
+ });
});
(superset) 03/04: fix: database version field (#25898)
Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
michaelsmolina pushed a commit to branch 3.0
in repository https://gitbox.apache.org/repos/asf/superset.git
commit 8c099a3f6f455c219620efce596a442edb9f7e78
Author: Beto Dealmeida <ro...@dealmeida.net>
AuthorDate: Tue Nov 7 20:55:03 2023 -0500
fix: database version field (#25898)
(cherry picked from commit 06ffcd29e2450d6b98cf38c8317e555b190d710b)
---
.../src/features/databases/DatabaseModal/ExtraOptions.tsx | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/superset-frontend/src/features/databases/DatabaseModal/ExtraOptions.tsx b/superset-frontend/src/features/databases/DatabaseModal/ExtraOptions.tsx
index 207e197cd4..55c3875f98 100644
--- a/superset-frontend/src/features/databases/DatabaseModal/ExtraOptions.tsx
+++ b/superset-frontend/src/features/databases/DatabaseModal/ExtraOptions.tsx
@@ -541,7 +541,7 @@ const ExtraOptions = ({
</div>
<div className="input-container" data-test="version-spinbutton-test">
<input
- type="number"
+ type="text"
name="version"
placeholder={t('Version number')}
onChange={onExtraInputChange}
@@ -550,8 +550,8 @@ const ExtraOptions = ({
</div>
<div className="helper">
{t(
- 'Specify the database version. This should be used with ' +
- 'Presto in order to enable query cost estimation.',
+ 'Specify the database version. This is used with Presto for query cost ' +
+ 'estimation, and Dremio for syntax changes, among others.',
)}
</div>
</StyledInputContainer>
(superset) 01/04: fix(charts): Time grain is None when dataset uses Jinja (#25842)
Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
michaelsmolina pushed a commit to branch 3.0
in repository https://gitbox.apache.org/repos/asf/superset.git
commit 756324d7132db12c6825d4aec13c6a3996d68f10
Author: Antonio Rivero <38...@users.noreply.github.com>
AuthorDate: Mon Nov 6 18:51:28 2023 +0100
fix(charts): Time grain is None when dataset uses Jinja (#25842)
(cherry picked from commit 7536dd12cdd58a1bca7d72952a2b74641f16c959)
---
.../superset-ui-core/src/query/normalizeTimeColumn.ts | 5 +----
.../superset-ui-core/test/query/normalizeTimeColumn.test.ts | 8 +++++---
.../test/MixedTimeseries/buildQuery.test.ts | 1 +
.../plugin-chart-echarts/test/Timeseries/buildQuery.test.ts | 4 ++--
.../plugin-chart-pivot-table/src/plugin/buildQuery.ts | 6 +-----
.../plugin-chart-pivot-table/test/plugin/buildQuery.test.ts | 13 +++++++++++++
6 files changed, 23 insertions(+), 14 deletions(-)
diff --git a/superset-frontend/packages/superset-ui-core/src/query/normalizeTimeColumn.ts b/superset-frontend/packages/superset-ui-core/src/query/normalizeTimeColumn.ts
index f7ea0d0e60..5fb9590c68 100644
--- a/superset-frontend/packages/superset-ui-core/src/query/normalizeTimeColumn.ts
+++ b/superset-frontend/packages/superset-ui-core/src/query/normalizeTimeColumn.ts
@@ -70,10 +70,7 @@ export function normalizeTimeColumn(
};
}
- const newQueryObject = omit(queryObject, [
- 'extras.time_grain_sqla',
- 'is_timeseries',
- ]);
+ const newQueryObject = omit(queryObject, ['is_timeseries']);
newQueryObject.columns = mutatedColumns;
return newQueryObject;
diff --git a/superset-frontend/packages/superset-ui-core/test/query/normalizeTimeColumn.test.ts b/superset-frontend/packages/superset-ui-core/test/query/normalizeTimeColumn.test.ts
index 22189b9055..2f6bdd0fb5 100644
--- a/superset-frontend/packages/superset-ui-core/test/query/normalizeTimeColumn.test.ts
+++ b/superset-frontend/packages/superset-ui-core/test/query/normalizeTimeColumn.test.ts
@@ -92,7 +92,9 @@ describe('GENERIC_CHART_AXES is disabled', () => {
datasource: '5__table',
viz_type: 'table',
granularity: 'time_column',
- extras: {},
+ extras: {
+ time_grain_sqla: 'P1Y',
+ },
time_range: '1 year ago : 2013',
orderby: [['count(*)', true]],
columns: [
@@ -182,7 +184,7 @@ describe('GENERIC_CHART_AXES is enabled', () => {
datasource: '5__table',
viz_type: 'table',
granularity: 'time_column',
- extras: { where: '', having: '' },
+ extras: { where: '', having: '', time_grain_sqla: 'P1Y' },
time_range: '1 year ago : 2013',
orderby: [['count(*)', true]],
columns: [
@@ -240,7 +242,7 @@ describe('GENERIC_CHART_AXES is enabled', () => {
datasource: '5__table',
viz_type: 'table',
granularity: 'time_column',
- extras: { where: '', having: '' },
+ extras: { where: '', having: '', time_grain_sqla: 'P1Y' },
time_range: '1 year ago : 2013',
orderby: [['count(*)', true]],
columns: [
diff --git a/superset-frontend/plugins/plugin-chart-echarts/test/MixedTimeseries/buildQuery.test.ts b/superset-frontend/plugins/plugin-chart-echarts/test/MixedTimeseries/buildQuery.test.ts
index 15d9e2cbb6..7aef4f582a 100644
--- a/superset-frontend/plugins/plugin-chart-echarts/test/MixedTimeseries/buildQuery.test.ts
+++ b/superset-frontend/plugins/plugin-chart-echarts/test/MixedTimeseries/buildQuery.test.ts
@@ -307,6 +307,7 @@ test('should convert a queryObject with x-axis although FF is disabled', () => {
extras: {
having: '',
where: "(foo in ('a', 'b'))",
+ time_grain_sqla: 'P1W',
},
applied_time_extras: {},
columns: [
diff --git a/superset-frontend/plugins/plugin-chart-echarts/test/Timeseries/buildQuery.test.ts b/superset-frontend/plugins/plugin-chart-echarts/test/Timeseries/buildQuery.test.ts
index 611f021af1..8887342933 100644
--- a/superset-frontend/plugins/plugin-chart-echarts/test/Timeseries/buildQuery.test.ts
+++ b/superset-frontend/plugins/plugin-chart-echarts/test/Timeseries/buildQuery.test.ts
@@ -120,7 +120,7 @@ describe('GENERIC_CHART_AXES is enabled', () => {
expect.objectContaining({
granularity: 'time_column',
time_range: '1 year ago : 2013',
- extras: { having: '', where: '' },
+ extras: { having: '', where: '', time_grain_sqla: 'P1Y' },
columns: [
{
columnType: 'BASE_AXIS',
@@ -209,7 +209,7 @@ describe('GENERIC_CHART_AXES is disabled', () => {
expect.objectContaining({
granularity: 'time_column',
time_range: '1 year ago : 2013',
- extras: { having: '', where: '' },
+ extras: { having: '', where: '', time_grain_sqla: 'P1Y' },
columns: [
{
columnType: 'BASE_AXIS',
diff --git a/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/buildQuery.ts b/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/buildQuery.ts
index 55a6cefd08..4cd314e06f 100644
--- a/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/buildQuery.ts
+++ b/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/buildQuery.ts
@@ -16,8 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/
-import omit from 'lodash/omit';
-
import {
AdhocColumn,
buildQueryContext,
@@ -72,9 +70,7 @@ export default function buildQuery(formData: PivotTableQueryFormData) {
}
return [
{
- ...(hasGenericChartAxes
- ? omit(baseQueryObject, ['extras.time_grain_sqla'])
- : baseQueryObject),
+ ...baseQueryObject,
orderby: orderBy,
columns,
},
diff --git a/superset-frontend/plugins/plugin-chart-pivot-table/test/plugin/buildQuery.test.ts b/superset-frontend/plugins/plugin-chart-pivot-table/test/plugin/buildQuery.test.ts
index 0e29de9196..bff468232f 100644
--- a/superset-frontend/plugins/plugin-chart-pivot-table/test/plugin/buildQuery.test.ts
+++ b/superset-frontend/plugins/plugin-chart-pivot-table/test/plugin/buildQuery.test.ts
@@ -121,3 +121,16 @@ test('should fallback to formData.time_grain_sqla if extra_form_data.time_grain_
expressionType: 'SQL',
});
});
+
+test('should not omit extras.time_grain_sqla from queryContext so dashboards apply them', () => {
+ Object.defineProperty(supersetCoreModule, 'hasGenericChartAxes', {
+ value: true,
+ });
+ const modifiedFormData = {
+ ...formData,
+ extra_form_data: { time_grain_sqla: TimeGranularity.QUARTER },
+ };
+ const queryContext = buildQuery(modifiedFormData);
+ const [query] = queryContext.queries;
+ expect(query.extras?.time_grain_sqla).toEqual(TimeGranularity.QUARTER);
+});