Giter Site home page Giter Site logo

langium-sql's People

Contributors

cam-m avatar gfontorbe avatar lotes avatar msujew avatar spoenemann 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  avatar  avatar  avatar  avatar  avatar

langium-sql's Issues

Missing for MySQL use cases

  • WITH clause
  • BETWEEN x AND y operator
  • LIKE operator
  • IN operator
  • IS operator
  • CONCAT || operator
  • several scalar functions
    • APPROX_COUNT_DISTINCT_ESTIMATE
    • unhex
    • concat
    • date
    • pow
    • date_trunc
    • last
    • u256_to_decimal
  • set functions
    • sum

Function calls

Needs to be refined

  • which functions are needed
  • find out differences between set functions and normal functions
  • find out how to define them as 'system library'
  • implement actual functions one by one

Create an interpreter

Requirements:

  • gets the SQL input model
  • gets tables via interface
  • evaluates the SQL query
  • returns the result

Good for:

  • value tests for ORDER BY and DISTINCT
  • demo page

Argument of type 'undefined' is not assignable to parameter of type 'never'

when i compile this project, i get error mssages as blow:

src/sql-scope-provider.ts:131:39 - error TS2345: Argument of type 'undefined' is not assignable to parameter of type 'never'.

131                     assertUnreachable(property);
                                          ~~~~~~~~

src/sql-scope-provider.ts:140:39 - error TS2345: Argument of type 'undefined' is not assignable to parameter of type 'never'.

140                     assertUnreachable(property);
                                          ~~~~~~~~

src/sql-scope-provider.ts:149:39 - error TS2345: Argument of type 'undefined' is not assignable to parameter of type 'never'.

149                     assertUnreachable(property);
                                          ~~~~~~~~

src/sql-scope-provider.ts:166:39 - error TS2345: Argument of type 'undefined' is not assignable to parameter of type 'never'.

166                     assertUnreachable(property);
                                          ~~~~~~~~

src/sql-scope-provider.ts:177:39 - error TS2345: Argument of type 'undefined' is not assignable to parameter of type 'never'.

177                     assertUnreachable(property);
                                          ~~~~~~~~

src/sql-scope-provider.ts:210:39 - error TS2345: Argument of type 'undefined' is not assignable to parameter of type 'never'.

210                     assertUnreachable(property);
                                          ~~~~~~~~

src/sql-scope-provider.ts:220:39 - error TS2345: Argument of type 'undefined' is not assignable to parameter of type 'never'.

220                     assertUnreachable(property);
                                          ~~~~~~~~

src/sql-scope-provider.ts:231:31 - error TS2345: Argument of type 'ColumnDefinition | ExpressionQuery | NumberLiteral | StringLiteral | CatalogDefinition | ... 45 more ... | TopClause' is not assignable to parameter of type 'never'.
  Type 'ColumnDefinition' is not assignable to type 'never'.

231             assertUnreachable(container);

my environment :
node: v18.20.1
typescript: v5.4.4

What can i do to fix it ?

Function call using SelectElements for parameters

I'm not sure the SimpleSelectStatement.select and PrimaryExpression.FunctionCall rules are correct.

I'm assuming FunctionCall is intended to parse system function calls (E.g. ABS() or DATEADD(), etc)

Problems:

  1. It currently uses the SelectElements rule for its params property;
{infer FunctionCall} function=GlobalReference '(' params=SelectElements? ')' 
      overClause=OverClause?

SelectElements:
    ('ALL'|distinct?='DISTINCT')? elements+=SelectElement (',' elements+=SelectElement)*
;
SelectElement infers SelectElement:
    {infer AllStar} '*'
    | {infer AllTable} variableName=[TableVariableSource:Identifier] '.' '*'
    | {infer ExpressionQuery} expr=Expression ('AS'? name=Identifier)?
;
  1. FunctionCall also directly defines the OVER statement, which should probably only be in SimpleSelectStatement in a window function expression

Happy to propose a fix if I've understood this correctly.

Data types

Check the chapters 3 to 13 from the Standard:

  • Numbers
  • Bit strings
  • Binary strings
  • Characters
  • Character strings
  • Temporal values
  • Boolean values
  • Collections
  • Row types
  • Nulls
  • Reference Types

Basic type system

There are several type categories. With this issue, we will implement a basic type system that understands

  • character strings
  • numbers
    • integers
    • reals
  • booleans

Each type has operators, casts to other types, assignment behaviors and functions that can be called.

Support for Sql Server dialect

Hi @Lotes,

Thanks for your part in creating this project - I'm considering including it in a project I work on - the current feature set is already very compelling.

I'm keen to add sql-server dialect support and thought it best to raise it here first in case contributing such a feature to this project is possible/preferable. I've been able to easily support sql-server's data types, but it seems syntax specific features (e.g square bracket for quoting keywords/spaces in table/column names) will require a separate / extended parser.

I've not tried the langium lib itself yet but have some experience building editor plugins using antlr4. Any pointers would be much appreciated.

Implement SELECT

SELECT arguments

  • all-star column *
  • all-table columns t.*
  • See also expressions

FROM arguments

  • table
  • sub query
  • joins

WHERE conditions

  • See also expressions

GROUP BY clause

  • TODO

ORDER BY clause

  • TODO

HAVING clause

  • TODO

LIMIT clause

  • TODO

Expressions

  • #4
  • #5
  • #6
  • #7
  • LIKE operator
  • SIMILAR TO operator
  • IS (NOT) operator
  • sub query
  • string concatenation operator
  • SUBSTRING(str FROM from FOR length)
  • boolean operators
  • arithmetic operators
  • relational operators

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.