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

Support of CTAS query #41

Closed
jubry opened this issue Oct 30, 2018 · 1 comment
Closed

Support of CTAS query #41

jubry opened this issue Oct 30, 2018 · 1 comment

Comments

@jubry
Copy link

jubry commented Oct 30, 2018

Hello,

First of all, big thanks for your great work on that lib, we are using it and it works like a charm.

AWS has released an update a few weeks back for what they call CTAS queries:

https://docs.aws.amazon.com/athena/latest/ug/ctas.html

It offers great features, however, we hit a glitch using node-athena on that kind of query.

The "outputLocation" received in the response is not pointing to the csv result or the metadata file.
Instead, the response is s3://[bucket_name]/[path]/[query_id] without the file extension.

When running this kind of queries with node-athena, we hit an error as the s3 key does not exists.

  1. The key: s3://[bucket_name]/[path]/[query_id] doesn't exists.
  2. Only the .metadata file is generated.

We have been able to patch the lib so it can handle this kind of query.

We have a compiled working version available at:

https://github.com/jubry/node-athena

I'm not a coder, so i'm not pretending my patch is how we should handle things.

I just changed a few lines of code in one file (client.js):

  1. Adding a new property in the client config:
export interface AthenaClientConfig extends AthenaRequestConfig {
  pollingInterval?: number
  queryTimeout?: number
  concurrentExecMax?: number
  execRightCheckInterval?: number
  noResultExpected?: boolean
}

NB: noResultExpected?: boolean added

  1. Adding a condition for not trying to access the CSV file in that case:
      if (!config.noResultExpected) {
        const resultsStream = this.request.getResultsStream(
          queryExecution.ResultConfiguration.OutputLocation,
        )
        resultsStream.pipe(csvTransform)
      }
  

NB: if (!config.noResultExpected) { added

By doing that, we are able to keep using your library.

Would it be possible for you to implement such functionality in a proper way ?

It would be greatly appreciated.

Find here an sql statement to reproduce the problem:

CREATE TABLE database.table WITH 
( format = 'PARQUET', 
external_location = 's3://mybucket_name/') 
AS SELECT 1 as myfield

Let me know if you have any question about it.

Thanks in advance,

And again, congratulation for your great work.

Regards,

:)

@KoteiIto
Copy link
Owner

KoteiIto commented Nov 8, 2018

We support CTAS from v2.4.0.
Please set skipFetchResult to true to create client.

@KoteiIto KoteiIto closed this as completed Nov 8, 2018
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

2 participants