SQLExecuteQueryOperator to connect to Apache Kylin¶
Use the SQLExecuteQueryOperator
to execute SQL queries against an
Apache Kylin cluster.
Note
There is no dedicated operator for Apache Kylin.
Please use the SQLExecuteQueryOperator
instead.
Note
Make sure you have installed the necessary provider package (e.g. apache-airflow-providers-apache-kylin
)
to enable Apache Kylin support.
Using the Operator¶
Use the conn_id
argument to connect to your Apache Kylin instance where
the connection metadata is structured as follows:
Parameter |
Input |
---|---|
Host: string |
Kylin server hostname or IP address |
Schema: string |
The default project name (optional) |
Login: string |
Username for authentication (default: ADMIN) |
Password: string |
Password for authentication (default: KYLIN) |
Port: int |
Kylin service port (default: 7070) |
Extra: JSON |
Additional connection configuration, such as:
|
An example usage of the SQLExecuteQueryOperator to connect to Apache Kylin is as follows:
tests/system/apache/kylin/example_kylin.py
create_table_kylin_task = SQLExecuteQueryOperator(
task_id="create_table_kylin",
sql="""
CREATE TABLE IF NOT EXISTS kylin_example (
a VARCHAR(100),
b INT
)
""",
)
alter_table_kylin_task = SQLExecuteQueryOperator(
task_id="alter_table_kylin",
sql="ALTER TABLE kylin_example ADD COLUMN c INT",
)
insert_data_kylin_task = SQLExecuteQueryOperator(
task_id="insert_data_kylin",
sql="""
INSERT INTO kylin_example (a, b, c)
VALUES ('x', 10, 1), ('y', 20, 2), ('z', 30, 3)
""",
)
select_data_kylin_task = SQLExecuteQueryOperator(
task_id="select_data_kylin",
sql="SELECT * FROM kylin_example",
)
drop_table_kylin_task = SQLExecuteQueryOperator(
task_id="drop_table_kylin",
sql="DROP TABLE kylin_example",
)
Reference¶
For further information, see:
Note
Parameters provided directly via SQLExecuteQueryOperator() take precedence over those specified
in the Airflow connection metadata (such as schema
, login
, password
, etc).