Coder Social home page Coder Social logo

Comments (8)

universalmind303 avatar universalmind303 commented on June 11, 2024 1

@groobyming I ran into a similar issue here #1227.

If you want your dialect to "extend" an existing dialect, you can implement the dialect function

impl Dialect for MyDialect {
    fn dialect(&self) -> std::any::TypeId {
        std::any::TypeId::of::<HiveDialect>()
    }

This'll allow the parser to treat it as that dialect whenever there is a check for dialect_of!.

IMO, more logic needs to move out of the dialect_of! macro, and into the Dialect trait, but considering there are 100+ uses of dialect_of in the parser, it may not be practical to add every one of those checks to Dialect.

from sqlparser-rs.

groobyming avatar groobyming commented on June 11, 2024

@alamb Hi, could you please take a look at this issue? I didn't find any more instructions about this custom Dialect

from sqlparser-rs.

alamb avatar alamb commented on June 11, 2024

I am not sure what is going on @groobyming -- your description certainly sounds like a bug.

Maybe there is code in the parser that is special casing HiveDialect rather than using a trait method:

https://github.com/search?q=repo%3Asqlparser-rs%2Fsqlparser-rs%20HiveDialect&type=code

from sqlparser-rs.

groobyming avatar groobyming commented on June 11, 2024

@alamb Thanks, when I added the following code in src/dialect/tokenizer.rs, it worked for me, but I still don't know why it works
image

test success:
image
image

So if I want to extend my own dialect, do I need to modify the source code and then package it for release?

from sqlparser-rs.

alamb avatar alamb commented on June 11, 2024

So if I want to extend my own dialect, do I need to modify the source code and then package it for release?

that is one alternative

Another is to change the code so that rather than testing dilaect_of!(...) it would do something like self.supports_numeric_prefix() and adding fn supports_numeric_prefix to the the Dialect trait

from sqlparser-rs.

groobyming avatar groobyming commented on June 11, 2024

@alamb Thanks for the feedback! I'll create a PR to address this issue.
PR addressing: #1188

from sqlparser-rs.

alamb avatar alamb commented on June 11, 2024

Thanks @groobyming -- I will try and take a look at the outstanding sqlparser PRs next week sometime. I don't think I'll have a chance to do so this week

from sqlparser-rs.

groobyming avatar groobyming commented on June 11, 2024

@alamb OK,Thanks

from sqlparser-rs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.