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: Support USE CATALOG syntax and current_catalog() function #16926

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

flashmouse
Copy link

@flashmouse flashmouse commented Nov 24, 2024

I hereby agree to the terms of the CLA available at: https://docs.databend.com/dev/policies/cla/

Summary

Tests

  • Unit Test
  • Logic Test
  • Benchmark Test
  • No Test - Explain why

Type of change

  • Bug Fix (non-breaking change which fixes an issue)
  • New Feature (non-breaking change which adds functionality)
  • Breaking Change (fix or feature that could cause existing functionality not to work as expected)
  • Documentation Update
  • Refactoring
  • Performance Improvement
  • Other (please describe):

This change is Reviewable

@github-actions github-actions bot added the pr-feature this PR introduces a new feature to the codebase label Nov 24, 2024
@flashmouse
Copy link
Author

I observe that use_database statement is prior to use_catalog unless I quote #ident(catalog)

use catalog abc  // parse to UseDatabase{"catalog "} which is unexpected
use catalog `abc` //  parse to UseCatalog{"abc"} correctly

@b41sh b41sh self-requested a review November 24, 2024 15:23
let use_catalog = map(
rule! {
(USE ~ CATALOG) ~ #ident
},
Copy link
Member

Choose a reason for hiding this comment

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

remove the parenthesis will fix the matched as use database issues

        rule! {
            USE ~ CATALOG ~ #ident
        },

Copy link
Author

Choose a reason for hiding this comment

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

I removed the parenthesis but still the same result

Copy link
Member

@b41sh b41sh Nov 25, 2024

Choose a reason for hiding this comment

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

I made a mistake. It's okay to keep the parenthesis.
This problem should be caused by the MySQL client, you can use the BendSQL client to test this case. And please add some test cases to this file src/query/ast/tests/it/parser.rs for verification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-feature this PR introduces a new feature to the codebase
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature: Support USE CATALOG syntax and current_catalog() function
2 participants