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

feat: Add support for creation of streams on external tables #999

Conversation

adamantike
Copy link
Contributor

@adamantike adamantike commented May 10, 2022

Allow the creation of STREAMS on EXTERNAL TABLEs.

Test Plan

  • acceptance tests
  • unit tests

References

@adamantike
Copy link
Contributor Author

@alldoami, gentle ping, considering you reviewed #661

@alldoami
Copy link
Contributor

oops sorry! Thanks for the reminder!

@alldoami alldoami changed the title Streams: Add on_external_table bool to allow for creation of streams on external tables feat: Add on_external_table bool to allow for creation of streams on external tables May 16, 2022
@alldoami
Copy link
Contributor

/ok-to-test sha=c4214d2

@github-actions
Copy link

Integration tests failure for c4214d2

@adamantike adamantike force-pushed the feature/add-external-tables-to-streams branch from c4214d2 to c1a2d10 Compare May 18, 2022 13:25
@alldoami
Copy link
Contributor

/ok-to-test sha=c1a2d10

@github-actions
Copy link

Integration tests failure for c1a2d10

@adamantike adamantike force-pushed the feature/add-external-tables-to-streams branch from c1a2d10 to fc91cab Compare May 26, 2022 01:39
@alldoami
Copy link
Contributor

/ok-to-test sha=ce964ea

@Snowflake-Labs Snowflake-Labs deleted a comment from github-actions bot May 26, 2022
@github-actions
Copy link

Integration tests failure for ce964ea

@alldoami
Copy link
Contributor

/ok-to-test sha=b1fc73b

@github-actions
Copy link

Integration tests failure for b1fc73b

@sfc-gh-swinkler
Copy link
Collaborator

@adamantike I really like this, but request a change:

When you do 'show tables like 'TABLE_NAME'; there is an is_external column which indicates if it is external or not. So instead of introducing a new boolean variable, just read the table and determine whether it is external or no.

@adamantike adamantike force-pushed the feature/add-external-tables-to-streams branch from b1fc73b to 9b4d2bb Compare June 3, 2022 01:41
@adamantike adamantike changed the title feat: Add on_external_table bool to allow for creation of streams on external tables feat: Add support for creation of streams on external tables Jun 3, 2022
@adamantike
Copy link
Contributor Author

@sfc-gh-swinkler, I really liked your recommendation, the implementation is cleaner and simpler in comparison!

I have refactored the PR to go with that approach, and would appreciate a review to know if the table information retrieval is using the function you expected.

@adamantike adamantike force-pushed the feature/add-external-tables-to-streams branch from 9b4d2bb to 6b46356 Compare June 3, 2022 01:47
@sfc-gh-swinkler
Copy link
Collaborator

/ok-to-test sha=9cc539d

@github-actions
Copy link

github-actions bot commented Jun 3, 2022

Integration tests failure for 9cc539d

@sfc-gh-swinkler
Copy link
Collaborator

=== CONT  TestAcc_Stream
    stream_acceptance_test.go:16: Step 3/4 error: Error running apply: exit status 1
        Error: error creating externalTable STREAM_ON_EXTERNAL_TABLE: 001003 (42000): SQL compilation error:
        syntax error line 1 at position 219 unexpected ''CreatedDate''.
          on terraform_plugin_test.tf line 25, in resource "snowflake_external_table" "test_external_stream_table":
          25: resource "snowflake_external_table" "test_external_stream_table" {

Hi @adamantike can you please fix? One of acceptance tests is failing

Allow the creation of `STREAMS` on `EXTERNAL TABLE`s.
@adamantike adamantike force-pushed the feature/add-external-tables-to-streams branch from 9cc539d to b6a786b Compare June 3, 2022 22:34
@adamantike
Copy link
Contributor Author

I have added a fix for that syntax error, but it seems there's no way to test external tables within acceptance tests at the moment. Fixing that, and disabling auto_refresh, makes the test reach a point where it requires a valid S3 bucket:

=== CONT  TestAcc_Stream
    stream_acceptance_test.go:15: Step 1/1 error: Error running apply: exit status 1

        Error: error creating externalTable STREAM_ON_EXTERNAL_TABLE: 091017 (22000): S3 bucket 'com.example.bucket' does not exist or not authorized.

          on terraform_plugin_test.tf line 25, in resource "snowflake_external_table" "test_external_stream_table":
          25: resource "snowflake_external_table" "test_external_stream_table" {

I found that the other acceptance tests for External tables are behind a flag, so I duplicated that same behavior here. (reference: #426)

@sfc-gh-swinkler
Copy link
Collaborator

/ok-to-test sha=b6a786b

@github-actions
Copy link

github-actions bot commented Jun 3, 2022

Integration tests success for b6a786b

@adamantike
Copy link
Contributor Author

Now that acceptance tests are also fixed, I'm open to any feedback on this PR, so it can be merged!

Copy link
Collaborator

@sfc-gh-swinkler sfc-gh-swinkler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@sfc-gh-swinkler sfc-gh-swinkler merged commit 0ee1d55 into Snowflake-Labs:main Jun 7, 2022
@sfc-gh-swinkler
Copy link
Collaborator

@adamantike thanks for your contribution! This is great 👍

@adamantike adamantike deleted the feature/add-external-tables-to-streams branch June 7, 2022 21:02
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

Successfully merging this pull request may close these issues.

3 participants