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

Add option to output DML lines #289

Open
wey-gu opened this issue Sep 11, 2023 · 5 comments
Open

Add option to output DML lines #289

wey-gu opened this issue Sep 11, 2023 · 5 comments
Labels
type/feature req Type: feature request

Comments

@wey-gu
Copy link
Contributor

wey-gu commented Sep 11, 2023

Recently I wanted to transfer my CSV files into ngql DML lines, so I quickly changed as follows to do so.

I wonder if someone else has such a requirement, too, If yes, maybe I could PR to add an option to output to log instead of stdout.

@veezhang do you think this feature may be reasonable or not?

diff --git a/pkg/spec/v3/edge.go b/pkg/spec/v3/edge.go
index 71c771a..e88664c 100644
--- a/pkg/spec/v3/edge.go
+++ b/pkg/spec/v3/edge.go
@@ -193,7 +193,11 @@ func (e *Edge) Validate() error {
 }
 
 func (e *Edge) Statement(records ...Record) (statement string, nRecord int, err error) {
-       return e.fnStatement(records...)
+       statement, nRecord, err = e.fnStatement(records...)
+       if err == nil && statement != "" {
+               fmt.Println("Generated command:", statement)
+       }
+       return statement, nRecord, err
 }
 
 func (e *Edge) insertStatement(records ...Record) (statement string, nRecord int, err error) {
diff --git a/pkg/spec/v3/node.go b/pkg/spec/v3/node.go
index 2c3929e..b084028 100644
--- a/pkg/spec/v3/node.go
+++ b/pkg/spec/v3/node.go
@@ -147,7 +147,11 @@ func (n *Node) Validate() error {
 }
 
 func (n *Node) Statement(records ...Record) (statement string, nRecord int, err error) {
-       return n.fnStatement(records...)
+       statement, nRecord, err = n.fnStatement(records...)
+       if err == nil && statement != "" {
+               fmt.Println("Generated command:", statement)
+       }
+       return statement, nRecord, err
 }
 
 func (n *Node) insertStatement(records ...Record) (statement string, nRecord int, err error) {
@wey-gu wey-gu added the type/feature req Type: feature request label Sep 11, 2023
@veezhang
Copy link
Contributor

veezhang commented Sep 12, 2023

@wey-gu You just want to store the statement to a file instead of storing in nebula.?

@wey-gu
Copy link
Contributor Author

wey-gu commented Sep 12, 2023

@wey-gu You just want to store the statement to a file instead of storing in nebula.?

Yes, I generated a small dataset as CSV and was preparing for studio starter dataset, so I did this with above change :-P

Not sure how general this requirement could be to other users.

@veezhang
Copy link
Contributor

@wey-gu So, why not use nebula-importer tool to import directly?

  1. generated csv to ngql
  2. use studio to exec ngql

=>

  1. use nebula-importer import csv

@wey-gu
Copy link
Contributor Author

wey-gu commented Sep 12, 2023

@wey-gu So, why not use nebula-importer tool to import directly?

  1. generated csv to ngql
  2. use studio to exec ngql

=>

  1. use nebula-importer import csv

Yes, for pure import purposes, that's enough, only just this use case I had to prepare files for this

Maybe this isn't a general requirement at all.

@veezhang
Copy link
Contributor

@wey-gu Maybe studio should use csv as datasets instand of ngql?
csv has the following advantages:

  • smaller size
  • better readability
  • only care about data, nothing to do with syntax

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/feature req Type: feature request
Projects
None yet
Development

No branches or pull requests

2 participants