Skip to content

Commit

Permalink
clean
Browse files Browse the repository at this point in the history
  • Loading branch information
andyfengHKU committed Sep 19, 2023
1 parent f0db1c5 commit 2b20060
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 20 deletions.
13 changes: 7 additions & 6 deletions src/binder/bind/bind_reading_clause.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#include "binder/binder.h"
#include "binder/expression/literal_expression.h"
#include "binder/query/reading_clause/bound_in_query_call.h"
#include "binder/query/reading_clause/bound_load_from.h"
#include "binder/query/reading_clause/bound_match_clause.h"
#include "binder/query/reading_clause/bound_unwind_clause.h"
#include "binder/query/reading_clause/bound_load_from.h"
#include "common/exception/binder.h"
#include "parser/query/reading_clause/in_query_call_clause.h"
#include "parser/query/reading_clause/unwind_clause.h"
#include "parser/query/reading_clause/load_from.h"
#include "parser/query/reading_clause/unwind_clause.h"
#include "processor/operator/persistent/reader/csv_reader.h"

using namespace kuzu::common;
Expand Down Expand Up @@ -115,10 +115,11 @@ std::unique_ptr<BoundReadingClause> Binder::bindInQueryCall(const ReadingClause&
std::unique_ptr<BoundReadingClause> Binder::bindLoadFrom(
const parser::ReadingClause& readingClause) {
auto& loadFrom = reinterpret_cast<const LoadFrom&>(readingClause);
auto readerConfig = std::make_unique<ReaderConfig>();
readerConfig->csvReaderConfig = bindParsingOptions(loadFrom.getParsingOptionsRef());
readerConfig->filePaths = bindFilePaths(loadFrom.getFilePaths());
readerConfig->fileType = bindFileType(readerConfig->filePaths);
auto csvReaderConfig = bindParsingOptions(loadFrom.getParsingOptionsRef());
auto filePaths = bindFilePaths(loadFrom.getFilePaths());
auto fileType = bindFileType(filePaths);
auto readerConfig =
std::make_unique<ReaderConfig>(fileType, std::move(filePaths), std::move(csvReaderConfig));
if (readerConfig->fileType != FileType::CSV) {
throw BinderException("Load from non-csv file is not supported.");

Check warning on line 124 in src/binder/bind/bind_reading_clause.cpp

View check run for this annotation

Codecov / codecov/patch

src/binder/bind/bind_reading_clause.cpp#L124

Added line #L124 was not covered by tests
}
Expand Down
2 changes: 1 addition & 1 deletion src/binder/bound_statement_visitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ void BoundStatementVisitor::visitReadingClause(const BoundReadingClause& reading
} break;
case ClauseType::LOAD_FROM: {
visitLoadFrom(readingClause);
} break ;
} break;
default:
throw NotImplementedException("BoundStatementVisitor::visitReadingClause");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ struct ReaderFunctions {
}
static void validateNPYFiles(const common::ReaderConfig& config);


static std::vector<FileBlocksInfo> countRowsNoOp(
const common::ReaderConfig& config, storage::MemoryManager* memoryManager);
static std::vector<FileBlocksInfo> countRowsInNodeCSVFile(
Expand Down
2 changes: 1 addition & 1 deletion src/parser/transform/transform_reading_clause.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include "common/exception/not_implemented.h"
#include "parser/query/reading_clause/in_query_call_clause.h"
#include "parser/query/reading_clause/load_from.h"
#include "parser/query/reading_clause/match_clause.h"
#include "parser/query/reading_clause/unwind_clause.h"
#include "parser/query/reading_clause/load_from.h"
#include "parser/transformer.h"

using namespace kuzu::common;
Expand Down
2 changes: 1 addition & 1 deletion src/planner/plan/plan_read.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "binder/query/reading_clause/bound_match_clause.h"
#include "binder/query/reading_clause/bound_load_from.h"
#include "binder/query/reading_clause/bound_match_clause.h"
#include "planner/query_planner.h"

using namespace kuzu::common;
Expand Down
2 changes: 1 addition & 1 deletion test/test_files/copy/copy_to.test
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Binder exception: Cannot find property non_prop for a.
-LOG Non-Query command
-STATEMENT COPY (EXPLAIN MATCH (p:person) RETURN p.ID) TO "test.csv"
---- error
Parser exception: mismatched input 'EXPLAIN' expecting {CALL, OPTIONAL, MATCH, UNWIND, CREATE, MERGE, SET, DELETE, WITH, RETURN} (line: 1, offset: 6)
Parser exception: mismatched input 'EXPLAIN' expecting {CALL, LOAD, OPTIONAL, MATCH, UNWIND, CREATE, MERGE, SET, DELETE, WITH, RETURN} (line: 1, offset: 6)
"COPY (EXPLAIN MATCH (p:person) RETURN p.ID) TO "test.csv""
^^^^^^^

Expand Down
7 changes: 0 additions & 7 deletions test/test_files/exceptions/parser/syntax_error.test
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@ Parser exception: Query must conclude with RETURN clause (line: 1, offset: 0)
"MATCH (a:person);"
^^^^^

-CASE QueryNotConcludeWithReturn2
-STATEMENT MATCH (a:person) WITH *;
---- error
Parser exception: mismatched input ';' expecting {CALL, OPTIONAL, MATCH, UNWIND, CREATE, MERGE, SET, DELETE, WITH, RETURN, SP} (line: 1, offset: 23)
"MATCH (a:person) WITH *;"
^

-CASE InvalidNotEqualOperator)
-STATEMENT MATCH (a) WHERE a.age != 1 RETURN *;
---- error
Expand Down
15 changes: 13 additions & 2 deletions test/test_files/tinysnb/load_from/load_from.test
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@
--

-CASE LoadFromTest1
-STATEMENT LOAD FROM "${KUZU_ROOT_DIRECTORY}/dataset/tinysnb/eMeets.csv" (HEADER=True) RETURN *;
-STATEMENT LOAD FROM "${KUZU_ROOT_DIRECTORY}/dataset/tinysnb/eStudyAt.csv" (HEADER=True) RETURN column0, column1, column2, column3;
---- 3
0|1|2021|[wwAewsdndweusd,wek]
2|1|2020|[anew,jsdnwusklklklwewsd]
8|1|2020|[awndsnjwejwen,isuhuwennjnuhuhuwewe]
-STATEMENT LOAD FROM "${KUZU_ROOT_DIRECTORY}/dataset/tinysnb/vPerson.csv" (HEADER=True) WITH * WHERE column1 = 'Alice' RETURN concat(column0, 'aa'), column1;
---- 1
1
0aa|Alice
-STATEMENT LOAD FROM "${KUZU_ROOT_DIRECTORY}/dataset/tinysnb/vPerson.csv" (HEADER=True) WITH *
MATCH (a:person) WHERE a.ID > 8 AND a.fName = column1
RETURN a.ID, a.fName;
---- 2
10|Hubert Blaine Wolfeschlegelsteinhausenbergerdorff
9|Greg

0 comments on commit 2b20060

Please sign in to comment.