Skip to content

Commit

Permalink
CREATE TABLE simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
ea-rus committed Mar 7, 2024
1 parent 3043153 commit 194cf72
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
2 changes: 1 addition & 1 deletion mindsdb_sql/parser/dialects/mindsdb/lexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class MindsDBLexer(Lexer):
ignore_line_comment = r'--[^\n]*'

tokens = {
USE, DROP, CREATE, DESCRIBE, RETRAIN,REPLACE,
USE, DROP, CREATE, DESCRIBE, RETRAIN, REPLACE,

# Misc
SET, START, TRANSACTION, COMMIT, ROLLBACK, ALTER, EXPLAIN,
Expand Down
15 changes: 6 additions & 9 deletions mindsdb_sql/parser/dialects/mindsdb/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -690,16 +690,13 @@ def drop_table(self, p):
return DropTables(tables=[p.identifier], if_exists=p.if_exists_or_empty)

# create table
@_('CREATE TABLE identifier select', # TODO tests failing without it
'CREATE TABLE if_not_exists_or_empty identifier select',
'CREATE TABLE if_not_exists_or_empty identifier LPAREN select RPAREN',
'CREATE OR REPLACE TABLE identifier select',
'CREATE OR REPLACE TABLE identifier LPAREN select RPAREN')
@_(
'CREATE replace_or_empty TABLE if_not_exists_or_empty identifier select',
'CREATE replace_or_empty TABLE if_not_exists_or_empty identifier LPAREN select RPAREN',
)
def create_table(self, p):
# TODO create table with columns
is_replace = False
if hasattr(p, 'REPLACE'):
is_replace = True
is_replace = getattr(p, 'replace_or_empty', False)

return CreateTable(
name=p.identifier,
is_replace=is_replace,
Expand Down

0 comments on commit 194cf72

Please sign in to comment.