-
Notifications
You must be signed in to change notification settings - Fork 155
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
Running a SQL step after bulk insert into JDBC #411
Comments
Woow could be very useful for us . |
Hi! so you could hack this some way. steps:
- dataFrameName: table1
sql:
SELECT * FROM source
- dataFrameName: single_row_table
sql:
SELECT 'no_value' AS col
output:
- dataFrameName: table1
outputType: JDBC
...
- dataFrameName: single_row_table
outputType: JDBCQuery
outputOptions:
query:
CREATE INDEX … ON … |
Hi @lyogev , That seemed like a great idea. However, after trying, I get an error :
From what I understand by looking at the Metorikku code, It seems like it is using a preparedStatement and looking for a placeholder for each field of the destination table, which it can't find as the I am now going to try with a dummy SELECT query as a first part of the output, will let you know if I manage to get something : steps:
- dataFrameName: table1
sql:
SELECT * FROM source
- dataFrameName: single_row_table
sql:
SELECT 'no_value' AS col
output:
- dataFrameName: table1
outputType: JDBC
...
- dataFrameName: single_row_table
outputType: JDBCQuery
outputOptions:
query:
SELECT 1 from dual where 1 = $1;
CREATE INDEX … ON … |
The SELECT doesn't work :
So I tried : outputOptions:
query:
INSERT INTO dummy_table(dummy_field) VALUES (?);
CREATE INDEX index_test ON test_table(test_field(30)); But I get a syntax error, I understand that So unfortunately I don't think it is doable this way... Maybe if the yaml could support a syntax with outputOptions:
queries: ? What do you think ? Do you have any idea from those tests @lyogev ? |
I've opened this PR for this #414 |
Worked like a charm ! Thanks a lot 👍 🎉 |
Hello,
When using metorikku with a JDBC output, is it possible to add custom SQL after a bulk insert ?
We'd like to run some SQL on the target JDBC to add some indexes on the created tables :
CREATE INDEX … ON …;
First, we thought of adding the « truncate : true » option so that the tables are not dropped but wiped instead, so the indexes would not be deleted at each ingestion.
However, this limits the schema evolution : if the schema in the input changes, the job will fail.
I was wondering if it could be possible to keep the default
truncate: false
, but add some SQL statement (creating indexes) that would be ran after the output is written.This would allow schema evolution while recreating the indexes at each ingestion.
Do you know if there is a way to achieve this with Metorikku ?
I hope the explanation is precise enough. Thank you in advance for your answer !
The text was updated successfully, but these errors were encountered: