Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change copy from npy keyword #1438

Merged
merged 1 commit into from
Apr 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dataset/npy-1d/copy.cypher
Original file line number Diff line number Diff line change
@@ -1 +1 @@
copy npytable fromnpy ("dataset/npy-1d/one_dim_int64.npy", "dataset/npy-1d/one_dim_int32.npy", "dataset/npy-1d/one_dim_int16.npy", "dataset/npy-1d/one_dim_double.npy", "dataset/npy-1d/one_dim_float.npy");
npy copy npytable from ("dataset/npy-1d/one_dim_int64.npy", "dataset/npy-1d/one_dim_int32.npy", "dataset/npy-1d/one_dim_int16.npy", "dataset/npy-1d/one_dim_double.npy", "dataset/npy-1d/one_dim_float.npy");
2 changes: 1 addition & 1 deletion dataset/npy-20k/copy.cypher
Original file line number Diff line number Diff line change
@@ -1 +1 @@
copy npytable fromNPY ("dataset/npy-20k/id_int64.npy", "dataset/npy-20k/two_dim_float.npy");
npy copy npytable from ("dataset/npy-20k/id_int64.npy", "dataset/npy-20k/two_dim_float.npy");
2 changes: 1 addition & 1 deletion dataset/npy-2d/copy.cypher
Original file line number Diff line number Diff line change
@@ -1 +1 @@
copy npytable fromNPY ("dataset/npy-2d/id_int64.npy", "dataset/npy-2d/two_dim_int64.npy", "dataset/npy-2d/two_dim_int32.npy", "dataset/npy-2d/two_dim_int16.npy", "dataset/npy-2d/two_dim_double.npy", "dataset/npy-2d/two_dim_float.npy");
npy copy npytable from ("dataset/npy-2d/id_int64.npy", "dataset/npy-2d/two_dim_int64.npy", "dataset/npy-2d/two_dim_int32.npy", "dataset/npy-2d/two_dim_int16.npy", "dataset/npy-2d/two_dim_double.npy", "dataset/npy-2d/two_dim_float.npy");
2 changes: 1 addition & 1 deletion dataset/npy-3d/copy.cypher
Original file line number Diff line number Diff line change
@@ -1 +1 @@
copy npytable FROMnpy ("dataset/npy-3d/id_int64.npy", "dataset/npy-3d/three_dim_int64.npy");
npy copy npytable FROM ("dataset/npy-3d/id_int64.npy", "dataset/npy-3d/three_dim_int64.npy");
4 changes: 2 additions & 2 deletions src/antlr4/Cypher.g4
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ kU_CopyCSV
: COPY SP oC_SchemaName SP FROM SP kU_FilePaths ( SP? '(' SP? kU_ParsingOptions SP? ')' )? ;

kU_CopyNPY
: COPY SP oC_SchemaName SP FROMNPY ( SP '(' SP? StringLiteral ( SP? ',' SP? StringLiteral )* ')' ) ;
: NPY SP COPY SP oC_SchemaName SP FROM ( SP '(' SP? StringLiteral ( SP? ',' SP? StringLiteral )* ')' ) ;

kU_FilePaths
: '[' SP? StringLiteral ( SP? ',' SP? StringLiteral )* ']'
Expand All @@ -39,7 +39,7 @@ COPY : ( 'C' | 'c' ) ( 'O' | 'o' ) ( 'P' | 'p') ( 'Y' | 'y' ) ;

FROM : ( 'F' | 'f' ) ( 'R' | 'r' ) ( 'O' | 'o' ) ( 'M' | 'm' );

FROMNPY : ( 'F' | 'f' ) ( 'R' | 'r' ) ( 'O' | 'o' ) ( 'M' | 'm' ) ( 'N' | 'n' ) ( 'P' | 'p' ) ( 'Y' | 'y' ) ;
NPY : ( 'N' | 'n' ) ( 'P' | 'p' ) ( 'Y' | 'y' ) ;

kU_DDL
: kU_CreateNode
Expand Down
2 changes: 1 addition & 1 deletion src/binder/bind/bind_copy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ std::unique_ptr<BoundStatement> Binder::bindCopy(const Statement& statement) {
std::unordered_map<common::property_id_t, std::string> propertyToNpyMap;
if (expectedFileType == common::CopyDescription::FileType::UNKNOWN &&
actualFileType == common::CopyDescription::FileType::NPY) {
throw BinderException("Please use COPY FROMNPY statement for copying npy files.");
throw BinderException("Please use NPY COPY statement for copying npy files.");
}
if (expectedFileType == common::CopyDescription::FileType::NPY &&
actualFileType != expectedFileType) {
Expand Down
14 changes: 7 additions & 7 deletions test/copy/copy_npy_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ TEST_F(CopyLargeNpyTest, CopyLargeNpyTest) {

TEST_F(CopyNpyFaultTest, CopyNpyInsufficientNumberOfProperties) {
conn->query("create node table npytable (id INT64,i64 INT64[12],PRIMARY KEY(id));");
validateCopyException("copy npytable fromnpy (\"" +
validateCopyException("npy copy npytable from (\"" +
TestHelper::appendKuzuRootPath("dataset/npy-3d/three_dim_int64.npy") +
"\");",
"Binder exception: Number of npy files is not equal to number of properties in table "
Expand All @@ -256,7 +256,7 @@ TEST_F(CopyNpyFaultTest, CopyNpyInsufficientNumberOfProperties) {
TEST_F(CopyNpyFaultTest, CopyNpyRedundantProperties) {
conn->query("create node table npytable (id INT64,i32 INT32, PRIMARY KEY(id));");
auto f32Path = TestHelper::appendKuzuRootPath("dataset/npy-20k/two_dim_float.npy");
validateCopyException("copy npytable fromnpy (\"" +
validateCopyException("npy copy npytable from (\"" +
TestHelper::appendKuzuRootPath("dataset/npy-20k/id_int64.npy") +
"\", \"" + f32Path + "\");",
"The type of npy file " + f32Path + " does not match the type defined in table npytable.");
Expand All @@ -265,7 +265,7 @@ TEST_F(CopyNpyFaultTest, CopyNpyRedundantProperties) {
TEST_F(CopyNpyFaultTest, CopyNpyVectorIntoScaler) {
conn->query("create node table npytable (id INT64,f32 FLOAT, PRIMARY KEY(id));");
auto f32Path = TestHelper::appendKuzuRootPath("dataset/npy-20k/two_dim_float.npy");
validateCopyException("copy npytable fromnpy (\"" +
validateCopyException("npy copy npytable from (\"" +
TestHelper::appendKuzuRootPath("dataset/npy-20k/id_int64.npy") +
"\", \"" + f32Path + "\");",
"Cannot copy a vector property in npy file " + f32Path +
Expand All @@ -275,7 +275,7 @@ TEST_F(CopyNpyFaultTest, CopyNpyVectorIntoScaler) {
TEST_F(CopyNpyFaultTest, CopyNpyWithMismatchedTypeOneDimensionTest) {
conn->query("create node table npytable (id INT64,i32 INT32, PRIMARY KEY(id));");
auto f32Path = TestHelper::appendKuzuRootPath("dataset/npy-1d/one_dim_float.npy");
validateCopyException("copy npytable fromnpy ( \"" +
validateCopyException("npy copy npytable from ( \"" +
TestHelper::appendKuzuRootPath("dataset/npy-1d/one_dim_int64.npy") +
"\", \"" + f32Path + "\");",
"The type of npy file " + f32Path + " does not match the type defined in table npytable.");
Expand All @@ -284,7 +284,7 @@ TEST_F(CopyNpyFaultTest, CopyNpyWithMismatchedTypeOneDimensionTest) {
TEST_F(CopyNpyFaultTest, CopyNpyWithMismatchedTypeTwoDimensionTest) {
conn->query("create node table npytable (id INT64,i32 INT32[10], PRIMARY KEY(id));");
auto f32Path = TestHelper::appendKuzuRootPath("dataset/npy-20k/two_dim_float.npy");
validateCopyException("copy npytable fromnpy (\"" +
validateCopyException("npy copy npytable from (\"" +
TestHelper::appendKuzuRootPath("dataset/npy-20k/id_int64.npy") +
"\", \"" + f32Path + "\");",
"The type of npy file " + f32Path + " does not match the type defined in table npytable.");
Expand All @@ -293,7 +293,7 @@ TEST_F(CopyNpyFaultTest, CopyNpyWithMismatchedTypeTwoDimensionTest) {
TEST_F(CopyNpyFaultTest, CopyNpyWithMismatchedDimensionTest) {
conn->query("create node table npytable (id INT64,f32 FLOAT[12],PRIMARY KEY(id));");
auto twoDimFloatNpyPath = TestHelper::appendKuzuRootPath("dataset/npy-20k/two_dim_float.npy");
validateCopyException("copy npytable fromnpy (\"" +
validateCopyException("npy copy npytable from (\"" +
TestHelper::appendKuzuRootPath("dataset/npy-20k/id_int64.npy") +
"\", \"" + twoDimFloatNpyPath + "\");",
"The shape of " + twoDimFloatNpyPath +
Expand All @@ -303,7 +303,7 @@ TEST_F(CopyNpyFaultTest, CopyNpyWithMismatchedDimensionTest) {
TEST_F(CopyNpyFaultTest, CopyNpyWithMismatchedLengthTest) {
conn->query("create node table npytable (id INT64,i64 INT64[12],PRIMARY KEY(id));");
validateCopyException(
"copy npytable fromnpy (\"" +
"npy copy npytable from (\"" +
TestHelper::appendKuzuRootPath("dataset/npy-20k/id_int64.npy") + "\", \"" +
TestHelper::appendKuzuRootPath("dataset/npy-3d/three_dim_int64.npy") + "\");",
"Number of rows in npy files is not equal to each other.");
Expand Down
Loading