Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#192 - Query Tracker shows "unsupported data type" for dynamic table system columns #224

Merged
merged 1 commit into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 24 additions & 3 deletions packages/ui/src/ui/pages/query-tracker/module/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,18 +277,37 @@ type QueryResult = {
yql_type_registry: TypeArray[];
};

type QueryResultRows = QueryResult['rows'];
type QueryResultRowSet = QueryResultRows[number];

/**
* Format limitations dictate system column names being prefixed by double dollar sign instead
* of a single on, here we just replace the stuff
*/
const mapQueryRowNames = (rows: QueryResultRows) => {
const replaceReg = /^\$\$/;
const replaceRows = (rowSet: QueryResultRowSet) =>
Object.keys(rowSet).reduce(
(result, next) => ({...result, [next.replace(replaceReg, '$')]: rowSet[next]}),
{} as QueryResultRowSet,
);

return rows.map(replaceRows);
};

export function readQueryResults(
query_id: string,
result_index = 0,
cursor: {start: number; end: number},
columns: string[],
settings: {
cellsSize: number;
},
): ThunkAction<Promise<QueryResult>, RootState, any, any> {
return (_dispatch, getState) => {
return async (_dispatch, getState) => {
const state = getState();
const {stage} = getQueryTrackerRequestOptions(state);
return ytApiV4Id.readQueryResults(YTApiId.readQueryResults, {
const result = (await ytApiV4Id.readQueryResults(YTApiId.readQueryResults, {
parameters: {
stage,
query_id,
Expand All @@ -298,6 +317,7 @@ export function readQueryResults(
output_format: {
$value: 'web_json',
$attributes: {
column_names: columns,
value_format: 'yql',
field_weight_limit: settings?.cellsSize,
encode_utf8: 'false',
Expand All @@ -306,7 +326,8 @@ export function readQueryResults(
},
},
setup: getQTApiSetup(),
});
})) as QueryResult;
return {...result, rows: mapQueryRowNames(result.rows)};
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ export function loadQueryResult(
start: 0,
end: settings.pageSize,
},
columns.map(({name}) => name),
{cellsSize: settings.cellSize},
),
),
Expand Down Expand Up @@ -205,6 +206,8 @@ export function updateQueryResult(

const startPage = page * settings.pageSize;
const endPage = startPage + settings.pageSize;
const cols =
(await dispatch(getQueryResultMeta(queryId, resultIndex)))?.schema.$value ?? [];
const result = await wrapApiPromiseByToaster(
dispatch(
readQueryResults(
Expand All @@ -214,6 +217,7 @@ export function updateQueryResult(
start: page * settings.pageSize,
end: endPage,
},
cols.map(({name}) => name),
{cellsSize: settings.cellSize},
),
),
Expand Down
Loading