Giter Club home page Giter Club logo

eosphoros-ai / sqlgpt-parser Goto Github PK

View Code? Open in Web Editor NEW
24.0 2.0 9.0 11.21 MB

sqlgpt-parser is a Python implementation of an SQL parser that effectively converts SQL statements into Abstract Syntax Trees (AST). By leveraging AST tree comparisons between two SQL queries, it becomes possible to achieve robust evaluation of text-to-SQL models.

License: Apache License 2.0

Makefile 0.01% Python 100.00% Shell 0.01%
ast parser python sql text-to-sql nl-to-sql

sqlgpt-parser's People

Contributors

luliwjc avatar qidi1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

sqlgpt-parser's Issues

关于sqlgpt-parser的一些问题

作者你好!我想问你一些关于sqlgpt-parser的一些问题,就是在使用解析器将sql语句解析为抽象语法树之后,我们该如何分析这棵抽象语法树呢?或者说,是否提供了对应的api可以帮助遍历抽象语法树,还有就是抽象语法树会以树节点的形式展示关于SQL的更多的细节,那么如何在遍历的过程中判断某些节点是否在原SQL语句中是否存在?比如原SQL语句中没有order by,但是在抽象语法树中会呈现,请问有没有对应的api可以帮助完成这件事情?还有我想问一下,在ast中各节点表示什么含义,比如querybody?哪些节点是父节点,哪些节点是子节点?

OceanBase语法树解析问题

  1. 不支持replace语句的解析
parse(input=sql, lexer=lexer, debug=debug, tracking=tracking, tokenfunc=tokenfunc)
  File "/home/jingshun.tq/.local/lib/python3.8/site-packages/ply/yacc.py", line 333, in parse
    return self.parseopt_notrack(input, lexer, debug, tracking, tokenfunc)
  File "/home/jingshun.tq/.local/lib/python3.8/site-packages/ply/yacc.py", line 1201, in parseopt_notrack
    tok = call_errorfunc(self.errorfunc, errtoken, self)
  File "/home/jingshun.tq/.local/lib/python3.8/site-packages/ply/yacc.py", line 192, in call_errorfunc
    r = errorfunc(token)
  File "/home/jingshun.tq/.local/lib/python3.8/site-packages/sqlgpt_parser/parser/oceanbase_parser/parser.py", line 3977, in p_error
    raise err
  File "<string>", line 1
    REPLACE INTO table_name (column1, column2) VALUES ('value1', 'value2')
    ^
SyntaxError: The current version does not support this SQL
>>>

Format function call and time interval error

Format SQL

SELECT date FROM `inv` WHERE date=DATE_ADD(creation_time, INTERVAL 4 HOUR)

But error happened

 def visit_function_call(self, node, unmangle_names):
        ret = ""
>       arguments = self._join_expressions(node.args, unmangle_names)
E       AttributeError: 'FunctionCall' object has no attribute 'args'

It is caused by FunctionCall not having attribute args but having attribute arguments.
And format code do not having visit_time_interval

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.