RedPillAnalytics / gradle-confluent

Apache License 2.0
22 stars 10 forks source link

pipelineExecute task not able to drop stream if its name is quoted #116

Closed bhanurz closed 3 years ago

bhanurz commented 3 years ago

Describe the bug When quotes are used in a stream name (for having case sensitive name), the pipelineExecute task does not drop this stream if it exists and instead tries to create it resulting in:

* What went wrong:
Execution failed for task ':pipelineExecute'.
> error_code: 40001: Cannot create stream 'testStream': A stream with name 'testStream' already exists

Query:

CREATE STREAM "testStream" (
    user_id int
) WITH (
    KAFKA_TOPIC = 'testStream',
    VALUE_FORMAT = 'JSON',
    PARTITIONS = 1
);

Command used: ./gradlew pipelineExecute --pipeline-dir exp-stream --stacktrace -i

To Reproduce Steps to reproduce the behaviour:

  1. Create a query file with following content:
    CREATE STREAM "testStream" (
    user_id int
    ) WITH (
    KAFKA_TOPIC = 'testStream',
    VALUE_FORMAT = 'JSON',
    PARTITIONS = 1
    );
  2. Execute this file with pipelineExecute task. This will create the stream.
  3. Execute this file again with pipelineExecute task.
  4. Query execution will fail saying stream already exists.

Expected behaviour At step 3, the pipelineExecute task should drop the stream and then create it.

Additional context The regex used in the plugin for extracting stream name does not consider quoted strings so it is not able to drop the query. Regex used in the plugin

bhanurz commented 3 years ago

@stewartbryson I have fixed and tested this locally. Please let me know if I can raise the PR.

stewartbryson commented 3 years ago

Do you see the SQL test scripts in src/test/resources? Can you put a test script in there that tests for this? After that, please do open a PR. Thanks for the contribution.

bhanurz commented 3 years ago

@stewartbryson Hi, I have added a test script and raise a PR, please check when possible: https://github.com/RedPillAnalytics/gradle-confluent/pull/117

stewartbryson commented 3 years ago

Merged. Thanks again for the contribution. After you've tested, can you close the issue?

bhanurz commented 3 years ago

@stewartbryson Tested the release, it is working.