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

Is the script really recognize CLI options? #65

Open
simonNozaki opened this issue Mar 25, 2021 · 12 comments
Open

Is the script really recognize CLI options? #65

simonNozaki opened this issue Mar 25, 2021 · 12 comments

Comments

@simonNozaki
Copy link

I wonder whether there are some lack of codes on dynamoDBtoCSV.js.

I cloned this repository, thinking "Wow, this is what I exactly wanted".
And I ran the scripts along the instruction on README.

But there are so much "undefined"s on running it. As I inspected the code, maybe I think that lacks the some instances.
Adding the code below and modifying something related, It finally ran properly:

const options = program.opts();

I saw that the official instruction of the library "commander" tells us that we have to add the instance above.
https://www.npmjs.com/package/commander

If the scripts has some insufficient components, I will make a pull request.

Please ensure the real specification of this script.

Thanks!

@ArFe
Copy link
Contributor

ArFe commented Mar 29, 2021

I wonder whether there are some lack of codes on dynamoDBtoCSV.js.

I cloned this repository, thinking "Wow, this is what I exactly wanted".
And I ran the scripts along the instruction on README.

But there are so much "undefined"s on running it. As I inspected the code, maybe I think that lacks the some instances.
Adding the code below and modifying something related, It finally ran properly:

const options = program.opts();

I saw that the official instruction of the library "commander" tells us that we have to add the instance above.
https://www.npmjs.com/package/commander

If the scripts has some insufficient components, I will make a pull request.

Please ensure the real specification of this script.

Thanks!

I run into the same issue. The older version used to work though. I think commander changed. No sure if the owner is still active with this.

@edasque
Copy link
Owner

edasque commented Mar 29, 2021

I am.

I am in the process of re-building this, not quite from scratch but doing a deep cleanup of that code. I am guessing we didn't pin down the version of commander enough. Watch this space for updates.

E.D.

@edasque
Copy link
Owner

edasque commented Mar 29, 2021

If I were you, I would try treplacing the "commander": ">=2.2.0", line in package.json with something like "commander": "^2.2.0",

@ArFe
Copy link
Contributor

ArFe commented Mar 29, 2021 via email

@simonNozaki
Copy link
Author

@edasque

Thanks for replying, and I can understand the status of the repository.

If I were you, I would try treplacing the "commander": ">=2.2.0", line in package.json with something like "commander": "^2.2.0",
That is true, I could not be aware of it...

OK, I will watch this repository continuously.

@caiconkhicon
Copy link

Hi, I just bumped into this tool today, and the fix in this issue helped me run the program. However, it seems that the argument "--select" is not working. I am not sure if it is related or not. Can anyone please try it? Thanks

@simonNozaki
Copy link
Author

However, it seems that the argument "--select" is not working. I am not sure if it is related or not. Can anyone please try it? Thanks

We cannot approach to that problem only by given the info.
You have better to check or debug that CLI option by printing the code around here:

const query = {
  TableName: options.table,
  IndexName: options.index,
  Select: program.count ? "COUNT" : (program.select ? "SPECIFIC_ATTRIBUTES" : (program.index ? "ALL_PROJECTED_ATTRIBUTES" : "ALL_ATTRIBUTES")),  // <== maybe this is not working properly
  KeyConditionExpression: program.keyExpression,
  ExpressionAttributeValues: JSON.parse(options.keyExpressionValues),
  ProjectionExpression: program.select,
  Limit: 1000
};

@ArFe
Copy link
Contributor

ArFe commented Mar 31, 2021

Hi, I just bumped into this tool today, and the fix in this issue helped me run the program. However, it seems that the argument "--select" is not working. I am not sure if it is related or not. Can anyone please try it? Thanks

I just tested and it worked for me. Must be something else or the way you're using select... if you post the error, we might be able to help.

@caiconkhicon
Copy link

Hi, I just bumped into this tool today, and the fix in this issue helped me run the program. However, it seems that the argument "--select" is not working. I am not sure if it is related or not. Can anyone please try it? Thanks

I just tested and it worked for me. Must be something else or the way you're using select... if you post the error, we might be able to help.

Sure. It is not an error, but the output still has all attributes, while I only want to select some. Btw, I also add -v "{}" to every command to make it work as suggested here (#64 (comment)). For example:
node dynamoDBtoCSV.js -t userPool -p dev -v "{}" --select "username, id" -m 123456

If I use -d, it still prints out all rows before printing out the description.
node dynamoDBtoCSV.js -t userPool -p dev -v "{}" -d -m 123456

@ArFe
Copy link
Contributor

ArFe commented Mar 31, 2021

I'm not sure what it is yet, but it has to do with the -v "{}".
Try something like this instead of the above:
-k "primarypartitionkey = :v1" -v '{":v1": {"S": "primarypartitionkeyvalue"}}'
It's going to select only the specific primary partition key selected, but the --select will work properly.
Not sure if it helps though.

I will take a closer look to see why the -v "{}" does not work with the --select.

@ArFe
Copy link
Contributor

ArFe commented Mar 31, 2021

I just figure out the problem.
When there is no -k parameters (options.keyExpression is null), it uses the Scan Query, without any parameters...

if (options.describe) describeTable(scanQuery); if (options.keyExpression) queryDynamoDB({ "query": query, stats: {} }); else scanDynamoDB(scanQuery);

`const query = {
TableName: options.table,
IndexName: options.index,
Select: options.count ? "COUNT" : (options.select ? "SPECIFIC_ATTRIBUTES" : (options.index ? "ALL_PROJECTED_ATTRIBUTES" : "ALL_ATTRIBUTES")),
KeyConditionExpression: options.keyExpression,
ExpressionAttributeValues: JSON.parse(options.keyExpressionValues),
ProjectionExpression: options.select,
Limit: 1000
};

const scanQuery = {
TableName: options.table,
IndexName: options.index,
Limit: 1000
};`

If you change the scan query to below, it will work. I will add to the pull request:

const scanQuery = { TableName: options.table, IndexName: options.index, ProjectionExpression: options.select, Limit: 1000 };

@caiconkhicon
Copy link

@ArFe : Thanks for your help. I will try it today and tell you the result.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants