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

Fix the wrong parsing of creating materialized view statements #49

Merged
merged 3 commits into from
Feb 27, 2024

Conversation

Lance726
Copy link
Collaborator

@Lance726 Lance726 commented Feb 27, 2024

The correct syntax for create materialized view is:

CREATE MATERIALIZED VIEW [IF NOT EXISTS] [db.]table_name [ON CLUSTER] [TO[db.]name] [ENGINE = engine] [POPULATE] AS SELECT ...

Our original parsing implement from antlr, process was wrong, now it is fixed.

example:

CREATE
MATERIALIZED VIEW infra_bm.view_name 
    ON CLUSTER 'default_cluster' TO infra_bm.table_name
(
  `f1` DateTime64(3), 
  `f2` String, 
  `f3` String, 
  `f4` String, 
  `f5` String, 
  `f6` Int64
) AS
SELECT f1,
       f2,
       visitParamExtractString(properties, 'f3')   AS f3,
       visitParamExtractString(properties, 'f4')      AS f4,
       visitParamExtractString(properties, 'f5')    AS f5,
    visitParamExtractInt(properties, 'f6') AS f6
FROM
    infra_bm.table_name1
WHERE
    infra_bm.table_name1.event = 'test-event';

@coveralls
Copy link

coveralls commented Feb 27, 2024

Pull Request Test Coverage Report for Build 8062032829

Details

  • -4 of 15 (73.33%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.009%) to 56.407%

Changes Missing Coverage Covered Lines Changed/Added Lines %
parser/ast.go 7 9 77.78%
parser/parser_view.go 4 6 66.67%
Totals Coverage Status
Change from base Build 7853328021: -0.009%
Covered Lines: 5423
Relevant Lines: 9614

💛 - Coveralls

@Lance726
Copy link
Collaborator Author

Our original implementation is based on antlr, which looks a little different from the actual syntax.

@git-hulk git-hulk merged commit 78405c4 into AfterShip:master Feb 27, 2024
1 check passed
@Lance726 Lance726 deleted the fix-materialized-bug branch February 27, 2024 09:17
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.

3 participants