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

feat: validation now works for templated query #1119

Merged
merged 3 commits into from
Jan 6, 2023
Merged

Conversation

czgu
Copy link
Collaborator

@czgu czgu commented Jan 6, 2023

  • fixed an issue where templated_variables kept getting regenerated
  • make templated queries also get validated
  • make templated query render modal also show validation errors with highlights
    image

@czgu czgu requested a review from jczhong84 January 6, 2023 02:25
@czgu czgu marked this pull request as ready for review January 6, 2023 02:25
@@ -6,7 +6,6 @@ import {
ILinterWarning,
TableToken,
} from 'lib/sql-helper/sql-lexer';
import { isQueryUsingTemplating } from 'lib/templated-query/validation';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this util function is only used in this file. As it's not needed here, it can be deleted.

@@ -41,6 +104,13 @@ export const TemplatedQueryView: React.FC<ITemplatedQueryViewProps> = ({
)
);

const { validationErrorHighlights, queryValidationErrors, isValidating } =
useValidateQuery(
renderedQuery,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of 2 api calls here, I'm wondering if it'll be better to have the renderTemplatedQuery api to accept another parameter to indicate if it should also do the validation on the rendered query and return the validation result along with the rendered query?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm I don't want to tie the two API calls together too much. One is for rendering the template and the other is to do validation check (only if the validator is configured). Also in future, I am thinking that we can make template rendering different if it is for validation so that we can map back the validation result from rendered query to unrendered query

@czgu czgu merged commit 155baca into pinterest:master Jan 6, 2023
@czgu czgu deleted the lintfix branch January 6, 2023 21:22
rohan-sh1 pushed a commit to CAI-TECHNOLOGIES/cai-ext-db-explorer that referenced this pull request Feb 28, 2023
* feat: validation now works for templated query

* remove isQueryUsingTemplating
aidenprice pushed a commit to arrowtail-precision/querybook that referenced this pull request Jan 3, 2024
* feat: validation now works for templated query

* remove isQueryUsingTemplating
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants