Add COPY for import and export (#139)

This commit is contained in:
Daniel Lindner 2020-01-08 16:21:02 +01:00 committed by mrks
parent 907b668151
commit e3cfc80975
17 changed files with 3005 additions and 2718 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
/* A Bison parser, made by GNU Bison 3.3.2. */
/* A Bison parser, made by GNU Bison 3.4.1. */
/* Bison interface for Yacc-like parsers in C
@ -52,7 +52,7 @@
extern int hsql_debug;
#endif
/* "%code requires" blocks. */
#line 35 "bison_parser.y" /* yacc.c:1927 */
#line 35 "bison_parser.y"
// %code requires block
@ -76,7 +76,7 @@ extern int hsql_debug;
} \
}
#line 80 "bison_parser.h" /* yacc.c:1927 */
#line 80 "bison_parser.h"
/* Token type. */
#ifndef HSQL_TOKENTYPE
@ -123,80 +123,80 @@ extern int hsql_debug;
SQL_EXCEPT = 295,
SQL_EXISTS = 296,
SQL_EXTRACT = 297,
SQL_GLOBAL = 298,
SQL_HAVING = 299,
SQL_IMPORT = 300,
SQL_INSERT = 301,
SQL_ISNULL = 302,
SQL_OFFSET = 303,
SQL_RENAME = 304,
SQL_SCHEMA = 305,
SQL_SELECT = 306,
SQL_SORTED = 307,
SQL_TABLES = 308,
SQL_UNIQUE = 309,
SQL_UNLOAD = 310,
SQL_UPDATE = 311,
SQL_VALUES = 312,
SQL_AFTER = 313,
SQL_ALTER = 314,
SQL_CROSS = 315,
SQL_DELTA = 316,
SQL_FLOAT = 317,
SQL_GROUP = 318,
SQL_INDEX = 319,
SQL_INNER = 320,
SQL_LIMIT = 321,
SQL_LOCAL = 322,
SQL_MERGE = 323,
SQL_MINUS = 324,
SQL_ORDER = 325,
SQL_OUTER = 326,
SQL_RIGHT = 327,
SQL_TABLE = 328,
SQL_UNION = 329,
SQL_USING = 330,
SQL_WHERE = 331,
SQL_CALL = 332,
SQL_CASE = 333,
SQL_CHAR = 334,
SQL_DATE = 335,
SQL_DESC = 336,
SQL_DROP = 337,
SQL_ELSE = 338,
SQL_FILE = 339,
SQL_FROM = 340,
SQL_FULL = 341,
SQL_HASH = 342,
SQL_HINT = 343,
SQL_INTO = 344,
SQL_JOIN = 345,
SQL_LEFT = 346,
SQL_LIKE = 347,
SQL_LOAD = 348,
SQL_LONG = 349,
SQL_NULL = 350,
SQL_PLAN = 351,
SQL_SHOW = 352,
SQL_TEXT = 353,
SQL_THEN = 354,
SQL_TIME = 355,
SQL_VIEW = 356,
SQL_WHEN = 357,
SQL_WITH = 358,
SQL_ADD = 359,
SQL_ALL = 360,
SQL_AND = 361,
SQL_ASC = 362,
SQL_CSV = 363,
SQL_END = 364,
SQL_FOR = 365,
SQL_INT = 366,
SQL_KEY = 367,
SQL_NOT = 368,
SQL_OFF = 369,
SQL_SET = 370,
SQL_TBL = 371,
SQL_FORMAT = 298,
SQL_GLOBAL = 299,
SQL_HAVING = 300,
SQL_IMPORT = 301,
SQL_INSERT = 302,
SQL_ISNULL = 303,
SQL_OFFSET = 304,
SQL_RENAME = 305,
SQL_SCHEMA = 306,
SQL_SELECT = 307,
SQL_SORTED = 308,
SQL_TABLES = 309,
SQL_UNIQUE = 310,
SQL_UNLOAD = 311,
SQL_UPDATE = 312,
SQL_VALUES = 313,
SQL_AFTER = 314,
SQL_ALTER = 315,
SQL_CROSS = 316,
SQL_DELTA = 317,
SQL_FLOAT = 318,
SQL_GROUP = 319,
SQL_INDEX = 320,
SQL_INNER = 321,
SQL_LIMIT = 322,
SQL_LOCAL = 323,
SQL_MERGE = 324,
SQL_MINUS = 325,
SQL_ORDER = 326,
SQL_OUTER = 327,
SQL_RIGHT = 328,
SQL_TABLE = 329,
SQL_UNION = 330,
SQL_USING = 331,
SQL_WHERE = 332,
SQL_CALL = 333,
SQL_CASE = 334,
SQL_CHAR = 335,
SQL_COPY = 336,
SQL_DATE = 337,
SQL_DESC = 338,
SQL_DROP = 339,
SQL_ELSE = 340,
SQL_FILE = 341,
SQL_FROM = 342,
SQL_FULL = 343,
SQL_HASH = 344,
SQL_HINT = 345,
SQL_INTO = 346,
SQL_JOIN = 347,
SQL_LEFT = 348,
SQL_LIKE = 349,
SQL_LOAD = 350,
SQL_LONG = 351,
SQL_NULL = 352,
SQL_PLAN = 353,
SQL_SHOW = 354,
SQL_TEXT = 355,
SQL_THEN = 356,
SQL_TIME = 357,
SQL_VIEW = 358,
SQL_WHEN = 359,
SQL_WITH = 360,
SQL_ADD = 361,
SQL_ALL = 362,
SQL_AND = 363,
SQL_ASC = 364,
SQL_END = 365,
SQL_FOR = 366,
SQL_INT = 367,
SQL_KEY = 368,
SQL_NOT = 369,
SQL_OFF = 370,
SQL_SET = 371,
SQL_TOP = 372,
SQL_AS = 373,
SQL_BY = 374,
@ -231,10 +231,9 @@ extern int hsql_debug;
/* Value type. */
#if ! defined HSQL_STYPE && ! defined HSQL_STYPE_IS_DECLARED
union HSQL_STYPE
{
#line 95 "bison_parser.y" /* yacc.c:1927 */
#line 95 "bison_parser.y"
double fval;
int64_t ival;
@ -245,6 +244,7 @@ union HSQL_STYPE
hsql::SQLStatement* statement;
hsql::SelectStatement* select_stmt;
hsql::ImportStatement* import_stmt;
hsql::ExportStatement* export_stmt;
hsql::CreateStatement* create_stmt;
hsql::InsertStatement* insert_stmt;
hsql::DeleteStatement* delete_stmt;
@ -264,6 +264,7 @@ union HSQL_STYPE
hsql::LimitDescription* limit;
hsql::ColumnDefinition* column_t;
hsql::ColumnType column_type_t;
hsql::ImportType import_type_t;
hsql::GroupByDescription* group_t;
hsql::UpdateClause* update_t;
hsql::Alias* alias_t;
@ -278,9 +279,9 @@ union HSQL_STYPE
std::vector<hsql::OrderDescription*>* order_vec;
std::vector<hsql::WithDescription*>* with_description_vec;
#line 282 "bison_parser.h" /* yacc.c:1927 */
};
#line 283 "bison_parser.h"
};
typedef union HSQL_STYPE HSQL_STYPE;
# define HSQL_STYPE_IS_TRIVIAL 1
# define HSQL_STYPE_IS_DECLARED 1

View File

@ -102,6 +102,7 @@ int yyerror(YYLTYPE* llocp, SQLParserResult* result, yyscan_t scanner, const cha
hsql::SQLStatement* statement;
hsql::SelectStatement* select_stmt;
hsql::ImportStatement* import_stmt;
hsql::ExportStatement* export_stmt;
hsql::CreateStatement* create_stmt;
hsql::InsertStatement* insert_stmt;
hsql::DeleteStatement* delete_stmt;
@ -121,6 +122,7 @@ int yyerror(YYLTYPE* llocp, SQLParserResult* result, yyscan_t scanner, const cha
hsql::LimitDescription* limit;
hsql::ColumnDefinition* column_t;
hsql::ColumnType column_type_t;
hsql::ImportType import_type_t;
hsql::GroupByDescription* group_t;
hsql::UpdateClause* update_t;
hsql::Alias* alias_t;
@ -140,7 +142,7 @@ int yyerror(YYLTYPE* llocp, SQLParserResult* result, yyscan_t scanner, const cha
/*********************************
** Destructor symbols
*********************************/
%destructor { } <fval> <ival> <uval> <bval> <order_type> <datetime_field> <column_type_t>
%destructor { } <fval> <ival> <uval> <bval> <order_type> <datetime_field> <column_type_t> <import_type_t>
%destructor { free( ($$.name) ); free( ($$.schema) ); } <table_name>
%destructor { free( ($$) ); } <sval>
%destructor {
@ -167,15 +169,15 @@ int yyerror(YYLTYPE* llocp, SQLParserResult* result, yyscan_t scanner, const cha
%token CASCADE COLUMNS CONTROL DEFAULT EXECUTE EXPLAIN
%token INTEGER NATURAL PREPARE PRIMARY SCHEMAS
%token SPATIAL VARCHAR VIRTUAL DESCRIBE BEFORE COLUMN CREATE DELETE DIRECT
%token DOUBLE ESCAPE EXCEPT EXISTS EXTRACT GLOBAL HAVING IMPORT
%token DOUBLE ESCAPE EXCEPT EXISTS EXTRACT FORMAT GLOBAL HAVING IMPORT
%token INSERT ISNULL OFFSET RENAME SCHEMA SELECT SORTED
%token TABLES UNIQUE UNLOAD UPDATE VALUES AFTER ALTER CROSS
%token DELTA FLOAT GROUP INDEX INNER LIMIT LOCAL MERGE MINUS ORDER
%token OUTER RIGHT TABLE UNION USING WHERE CALL CASE CHAR DATE
%token OUTER RIGHT TABLE UNION USING WHERE CALL CASE CHAR COPY DATE
%token DESC DROP ELSE FILE FROM FULL HASH HINT INTO JOIN
%token LEFT LIKE LOAD LONG NULL PLAN SHOW TEXT THEN TIME
%token VIEW WHEN WITH ADD ALL AND ASC CSV END FOR INT KEY
%token NOT OFF SET TBL TOP AS BY IF IN IS OF ON OR TO
%token VIEW WHEN WITH ADD ALL AND ASC END FOR INT KEY
%token NOT OFF SET TOP AS BY IF IN IS OF ON OR TO
%token ARRAY CONCAT ILIKE SECOND MINUTE HOUR DAY MONTH YEAR
%token TRUE FALSE
@ -188,6 +190,7 @@ int yyerror(YYLTYPE* llocp, SQLParserResult* result, yyscan_t scanner, const cha
%type <prep_stmt> prepare_statement
%type <select_stmt> select_statement select_with_paren select_no_paren select_clause select_paren_or_clause
%type <import_stmt> import_statement
%type <export_stmt> export_statement
%type <create_stmt> create_statement
%type <insert_stmt> insert_statement
%type <delete_stmt> delete_statement truncate_statement
@ -197,7 +200,7 @@ int yyerror(YYLTYPE* llocp, SQLParserResult* result, yyscan_t scanner, const cha
%type <table_name> table_name
%type <sval> file_path prepare_target_query
%type <bval> opt_not_exists opt_exists opt_distinct opt_column_nullable
%type <uval> import_file_type opt_join_type
%type <uval> opt_join_type
%type <table> opt_from_clause from_clause table_ref table_ref_atomic table_ref_name nonjoin_table_ref_atomic
%type <table> join_clause table_ref_name_no_alias
%type <expr> expr operand scalar_expr unary_expr binary_expr logic_expr exists_expr extract_expr
@ -216,6 +219,9 @@ int yyerror(YYLTYPE* llocp, SQLParserResult* result, yyscan_t scanner, const cha
%type <alias_t> opt_table_alias table_alias opt_alias alias
%type <with_description_t> with_description
// ImportType is used for compatibility reasons
%type <import_type_t> opt_file_type file_type
%type <str_vec> ident_commalist opt_column_list
%type <expr_vec> expr_list select_list opt_literal_list literal_list hint_list opt_hints
%type <table_vec> table_ref_commalist
@ -302,12 +308,17 @@ statement:
| show_statement {
$$ = $1;
}
| import_statement {
$$ = $1;
}
| export_statement {
$$ = $1;
}
;
preparable_statement:
select_statement { $$ = $1; }
| import_statement { $$ = $1; }
| create_statement { $$ = $1; }
| insert_statement { $$ = $1; }
| delete_statement { $$ = $1; }
@ -374,24 +385,65 @@ execute_statement:
/******************************
* Import Statement
* IMPORT FROM TBL FILE 'test/students.tbl' INTO students
* COPY students FROM 'test/students.tbl' [WITH FORMAT TBL]
******************************/
import_statement:
IMPORT FROM import_file_type FILE file_path INTO table_name {
$$ = new ImportStatement((ImportType) $3);
IMPORT FROM file_type FILE file_path INTO table_name {
$$ = new ImportStatement($3);
$$->filePath = $5;
$$->schema = $7.schema;
$$->tableName = $7.name;
}
| COPY table_name FROM file_path opt_file_type {
$$ = new ImportStatement($5);
$$->filePath = $4;
$$->schema = $2.schema;
$$->tableName = $2.name;
}
;
import_file_type:
CSV { $$ = kImportCSV; }
file_type:
IDENTIFIER {
if (strcasecmp($1, "csv") == 0) {
$$ = kImportCSV;
} else if (strcasecmp($1, "tbl") == 0) {
$$ = kImportTbl;
} else if (strcasecmp($1, "binary") == 0 || strcasecmp($1, "bin") == 0) {
$$ = kImportBinary;
} else {
free($1);
yyerror(&yyloc, result, scanner, "File type is unknown.");
YYERROR;
}
free($1);
}
;
file_path:
string_literal { $$ = strdup($1->name); delete $1; }
;
opt_file_type:
WITH FORMAT file_type {
$$ = $3;
}
| /* empty */ { $$ = kImportAuto; }
;
/******************************
* Export Statement
* COPY students TO 'test/students.tbl' (WITH FORMAT TBL)
******************************/
export_statement:
COPY table_name TO file_path opt_file_type {
$$ = new ExportStatement($5);
$$->filePath = $4;
$$->schema = $2.schema;
$$->tableName = $2.name;
}
;
/******************************
* Show Statement
@ -421,11 +473,17 @@ show_statement:
* CREATE TABLE students FROM TBL FILE 'test/students.tbl'
******************************/
create_statement:
CREATE TABLE opt_not_exists table_name FROM TBL FILE file_path {
CREATE TABLE opt_not_exists table_name FROM IDENTIFIER FILE file_path {
$$ = new CreateStatement(kCreateTableFromTbl);
$$->ifNotExists = $3;
$$->schema = $4.schema;
$$->tableName = $4.name;
if (strcasecmp($6, "tbl") != 0) {
free($6);
yyerror(&yyloc, result, scanner, "File type is unknown.");
YYERROR;
}
free($6);
$$->filePath = $8;
}
| CREATE TABLE opt_not_exists table_name '(' column_def_commalist ')' {
@ -700,6 +758,7 @@ select_list:
opt_from_clause:
from_clause { $$ = $1; }
| /* empty */ { $$ = nullptr; }
;
from_clause:
FROM table_ref { $$ = $2; }
@ -723,6 +782,7 @@ opt_group:
opt_having:
HAVING expr { $$ = $2; }
| /* empty */ { $$ = nullptr; }
;
opt_order:
ORDER BY order_list { $$ = $3; }
@ -893,6 +953,7 @@ datetime_field:
| DAY { $$ = kDatetimeDay; }
| MONTH { $$ = kDatetimeMonth; }
| YEAR { $$ = kDatetimeYear; }
;
array_expr:
ARRAY '[' expr_list ']' { $$ = Expr::makeArray($3); }
@ -1022,6 +1083,7 @@ table_alias:
opt_table_alias:
table_alias
| /* empty */ { $$ = nullptr; }
;
alias:
@ -1033,6 +1095,7 @@ alias:
opt_alias:
alias
| /* empty */ { $$ = nullptr; }
;
/******************************

File diff suppressed because it is too large Load Diff

View File

@ -2,9 +2,9 @@
#define hsql_HEADER_H 1
#define hsql_IN_HEADER 1
#line 5 "flex_lexer.h"
#line 6 "flex_lexer.h"
#line 7 "flex_lexer.h"
#line 8 "flex_lexer.h"
#define YY_INT_ALIGNED short int
@ -733,6 +733,6 @@ extern int yylex \
#line 236 "flex_lexer.l"
#line 736 "flex_lexer.h"
#line 737 "flex_lexer.h"
#undef hsql_IN_HEADER
#endif /* hsql_HEADER_H */

View File

@ -44,7 +44,7 @@ static thread_local std::stringstream strbuf;
%option warn
%option case-insensitive
%option prefix="hsql_"
%option bison-locations
%option bison-locations
/* %option nodefault */
@ -97,6 +97,7 @@ ESCAPE TOKEN(ESCAPE)
EXCEPT TOKEN(EXCEPT)
EXISTS TOKEN(EXISTS)
EXTRACT TOKEN(EXTRACT)
FORMAT TOKEN(FORMAT)
GLOBAL TOKEN(GLOBAL)
HAVING TOKEN(HAVING)
IMPORT TOKEN(IMPORT)
@ -135,6 +136,7 @@ WHERE TOKEN(WHERE)
CALL TOKEN(CALL)
CASE TOKEN(CASE)
CHAR TOKEN(CHAR)
COPY TOKEN(COPY)
DATE TOKEN(DATE)
DESC TOKEN(DESC)
DROP TOKEN(DROP)
@ -164,7 +166,6 @@ ADD TOKEN(ADD)
ALL TOKEN(ALL)
AND TOKEN(AND)
ASC TOKEN(ASC)
CSV TOKEN(CSV)
END TOKEN(END)
FOR TOKEN(FOR)
INT TOKEN(INT)
@ -172,7 +173,6 @@ KEY TOKEN(KEY)
NOT TOKEN(NOT)
OFF TOKEN(OFF)
SET TOKEN(SET)
TBL TOKEN(TBL)
TOP TOKEN(TOP)
AS TOKEN(AS)
BY TOKEN(BY)
@ -193,7 +193,7 @@ TRUE TOKEN(TRUE)
FALSE TOKEN(FALSE)
/* Allow =/== see https://sqlite.org/lang_expr.html#collateop */
"==" TOKEN(EQUALS)
"==" TOKEN(EQUALS)
"!=" TOKEN(NOTEQUALS)
"<>" TOKEN(NOTEQUALS)
"<=" TOKEN(LESSEQ)

View File

@ -76,10 +76,11 @@ VALUES
DIRECT
SORTED
COPY
FORMAT
IMPORT
CSV
FILE
TBL
CONTROL
UPDATE

22
src/sql/ExportStatement.h Executable file
View File

@ -0,0 +1,22 @@
#ifndef SQLPARSER_EXPORT_STATEMENT_H
#define SQLPARSER_EXPORT_STATEMENT_H
#include "ImportStatement.h"
#include "SQLStatement.h"
namespace hsql {
// Represents SQL Export statements.
struct ExportStatement : SQLStatement {
ExportStatement(ImportType type);
virtual ~ExportStatement();
// ImportType is used for compatibility reasons
ImportType type;
char* filePath;
char* schema;
char* tableName;
};
} // namespace hsql
#endif

View File

@ -7,6 +7,8 @@ namespace hsql {
enum ImportType {
kImportCSV,
kImportTbl, // Hyrise file format
kImportBinary,
kImportAuto
};
// Represents SQL Import statements.

View File

@ -134,6 +134,20 @@ namespace hsql {
}
}
// ExportStatement
ExportStatement::ExportStatement(ImportType type) :
SQLStatement(kStmtExport),
type(type),
filePath(nullptr),
schema(nullptr),
tableName(nullptr) {};
ExportStatement::~ExportStatement() {
free(filePath);
free(schema);
free(tableName);
}
// ImportStatement
ImportStatement::ImportStatement(ImportType type) :
SQLStatement(kStmtImport),

View File

@ -11,5 +11,6 @@
#include "PrepareStatement.h"
#include "ExecuteStatement.h"
#include "ShowStatement.h"
#include "ExportStatement.h"
#endif // SQLPARSER_STATEMENTS_H

View File

@ -196,6 +196,40 @@ namespace hsql {
void printImportStatementInfo(const ImportStatement* stmt, uintmax_t numIndent) {
inprint("ImportStatement", numIndent);
inprint(stmt->filePath, numIndent + 1);
switch (stmt->type) {
case ImportType::kImportCSV:
inprint("CSV", numIndent + 1);
break;
case ImportType::kImportTbl:
inprint("TBL", numIndent + 1);
break;
case ImportType::kImportBinary:
inprint("BINARY", numIndent + 1);
break;
case ImportType::kImportAuto:
inprint("AUTO", numIndent + 1);
break;
}
inprint(stmt->tableName, numIndent + 1);
}
void printExportStatementInfo(const ExportStatement* stmt, uintmax_t numIndent) {
inprint("ExportStatement", numIndent);
inprint(stmt->filePath, numIndent + 1);
switch (stmt->type) {
case ImportType::kImportCSV:
inprint("CSV", numIndent + 1);
break;
case ImportType::kImportTbl:
inprint("TBL", numIndent + 1);
break;
case ImportType::kImportBinary:
inprint("BINARY", numIndent + 1);
break;
case ImportType::kImportAuto:
inprint("AUTO", numIndent + 1);
break;
}
inprint(stmt->tableName, numIndent + 1);
}
@ -241,6 +275,9 @@ namespace hsql {
case kStmtImport:
printImportStatementInfo((const ImportStatement*) stmt, 0);
break;
case kStmtExport:
printExportStatementInfo((const ExportStatement*) stmt, 0);
break;
default:
break;
}

View File

@ -14,6 +14,9 @@ namespace hsql {
// Prints a summary of the given ImportStatement with the given indentation.
void printImportStatementInfo(const ImportStatement* stmt, uintmax_t num_indent);
// Prints a summary of the given CopyStatement with the given indentation.
void printExportStatementInfo(const ExportStatement* stmt, uintmax_t num_indent);
// Prints a summary of the given InsertStatement with the given indentation.
void printInsertStatementInfo(const InsertStatement* stmt, uintmax_t num_indent);

View File

@ -10,8 +10,12 @@
!SELECT * FROM t WHERE a = ? AND b = ?;gibberish;
!SHOW COLUMNS;
!DESCRIBE;
!COPY;
!COPY students;
!COPY students FROM 'students_file' WITH FORMAT XYZ;
!COPY students TO 'students_file' WITH FORMAT XYZ;
!select a + 2 as b(spam, eggs) from B;
!WITH a AS SELECT 1 SELECT 1;
!WITH a AS (SELECT ) SELECT 1;
!WITH a AS (WITH b AS (SELECT 1) SELECT 1) SELECT 1; # We do not support nested WITH clauses
!WITH a AS (SELECT ) b AS (SELECT ) SELECT 1; # Missing comma between WITH descriptions
!WITH a AS (SELECT ) b AS (SELECT ) SELECT 1; # Missing comma between WITH descriptions

View File

@ -54,6 +54,17 @@ PREPARE prep2 FROM 'INSERT INTO test VALUES (?, 0, 0); INSERT INTO test VALUES (
EXECUTE prep_inst(1, 2, 3);
EXECUTE prep;
DEALLOCATE PREPARE prep;
# COPY
COPY students FROM 'student.tbl';
COPY students FROM 'file_path' WITH FORMAT TBL;
COPY students FROM 'file_path' WITH FORMAT CSV;
COPY students FROM 'file_path' WITH FORMAT BIN;
COPY students FROM 'file_path' WITH FORMAT BINARY;
COPY students TO 'student.tbl';
COPY students TO 'file_path' WITH FORMAT TBL;
COPY students TO 'file_path' WITH FORMAT CSV;
COPY students TO 'file_path' WITH FORMAT BIN;
COPY students TO 'file_path' WITH FORMAT BINARY;
# HINTS
SELECT * FROM test WITH HINT(NO_CACHE);
SELECT * FROM test WITH HINT(NO_CACHE, NO_SAMPLING);

View File

@ -205,6 +205,45 @@ TEST(DescribeStatementTest) {
ASSERT_STREQ(stmt->name, "students");
}
TEST(ImportStatementTest) {
TEST_PARSE_SINGLE_SQL(
"IMPORT FROM TBL FILE 'students_file' INTO students;",
kStmtImport,
ImportStatement,
result,
stmt);
ASSERT_EQ(stmt->type, kImportTbl);
ASSERT_NOTNULL(stmt->tableName);
ASSERT_STREQ(stmt->tableName, "students");
ASSERT_STREQ(stmt->filePath, "students_file");
}
TEST(CopyStatementTest) {
TEST_PARSE_SINGLE_SQL(
"COPY students FROM 'students_file' ;",
kStmtImport,
ImportStatement,
import_result,
import_stmt);
ASSERT_EQ(import_stmt->type, kImportAuto);
ASSERT_NOTNULL(import_stmt->tableName);
ASSERT_STREQ(import_stmt->tableName, "students");
ASSERT_STREQ(import_stmt->filePath, "students_file");
TEST_PARSE_SINGLE_SQL(
"COPY students TO 'students_file';",
kStmtExport,
ExportStatement,
export_result,
export_stmt);
ASSERT_EQ(export_stmt->type, kImportAuto);
ASSERT_NOTNULL(export_stmt->tableName);
ASSERT_STREQ(export_stmt->tableName, "students");
ASSERT_STREQ(export_stmt->filePath, "students_file");
}
SQLParserResult parse_and_move(std::string query) {
hsql::SQLParserResult result;

View File

@ -46,7 +46,7 @@ fi
#################################################
# Checking if the grammar is conflict free.
printf "\n${GREEN}Checking for conflicts in the grammer...${NC}\n"
printf "\n${GREEN}Checking for conflicts in the grammar...${NC}\n"
printf "${RED}"
make -C src/parser/ test >>/dev/null
CONFLICT_RET=$?