You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am currently working on a project using DolphinScheduler to run SQL scripts, where I need to dynamically concatenate table names based on a varchar-type parameter. However, when I pass the parameter through DolphinScheduler, it automatically adds single quotes around the varchar value, causing errors in my SQL script.
Issue:
In my use case, I have different workflows that insert into different tables based on the passed parameter. For example, the table name can be sales_site or sales_beijing, depending on the parameter value. But when I pass a parameter like ${table_suffix} through DolphinScheduler, it results in INSERT INTO sales_'site' instead of INSERT INTO sales_site, leading to SQL errors.
What I need:
I am looking for a way to dynamically concatenate a varchar-type parameter (e.g., site, beijing) into my SQL without it being wrapped in single quotes. This is especially needed when working with dynamic table names.
What I tried:
I attempted to use CONCAT() in the SQL script, but DolphinScheduler still adds quotes around the varchar parameter, treating it as a string.
I also tried using a direct replacement like sales_${table_suffix}, but that also results in quoted values.
Sample SQL:
INSERT INTO sales_${table_suffix} (column1, column2, ...)
SELECT column1, column2
FROM source_table
WHERE some_condition ='value';
When ${table_suffix} is passed as 'site', it becomes sales_'site' instead of sales_site.
Environment:
DolphinScheduler version: (mention your version)
Database: Doris
Task Type: SQL
Question:
Is there a way to pass a varchar parameter dynamically in DolphinScheduler SQL tasks without it being enclosed in single quotes? Alternatively, is there a workaround or best practice for handling dynamic table names based on parameters?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Description:
I am currently working on a project using DolphinScheduler to run SQL scripts, where I need to dynamically concatenate table names based on a varchar-type parameter. However, when I pass the parameter through DolphinScheduler, it automatically adds single quotes around the varchar value, causing errors in my SQL script.
Issue:
In my use case, I have different workflows that insert into different tables based on the passed parameter. For example, the table name can be
sales_site
orsales_beijing
, depending on the parameter value. But when I pass a parameter like${table_suffix}
through DolphinScheduler, it results inINSERT INTO sales_'site'
instead ofINSERT INTO sales_site
, leading to SQL errors.What I need:
I am looking for a way to dynamically concatenate a varchar-type parameter (e.g.,
site
,beijing
) into my SQL without it being wrapped in single quotes. This is especially needed when working with dynamic table names.What I tried:
CONCAT()
in the SQL script, but DolphinScheduler still adds quotes around the varchar parameter, treating it as a string.sales_${table_suffix}
, but that also results in quoted values.Sample SQL:
When ${table_suffix} is passed as 'site', it becomes sales_'site' instead of sales_site.
Environment:
DolphinScheduler version: (mention your version)
Database: Doris
Task Type: SQL
Question:
Is there a way to pass a varchar parameter dynamically in DolphinScheduler SQL tasks without it being enclosed in single quotes? Alternatively, is there a workaround or best practice for handling dynamic table names based on parameters?
Beta Was this translation helpful? Give feedback.
All reactions