Package: vdk-impala
This plugin allows vdk-core to interface with and execute queries against an Impala database.FeaturesIt provides a powerful recovery mechanism handling a lot of challenges - like eventual consistency issues in Impala and more. In one production deployment of VDK it was able to improve SLA of Impala from 95% (queries directly to Impala) to 99% (queries using VDK to Impala).It automatically classifies error based on who is best responsible to handle them - user (job owner) vs platform (infra owner).It provides a default implementation of Kimball templates for generatingSCD1,SCD2dimension tables,Periodic Snapshot Fact TableIt can collect lineage data, assuming a lineage logger has been provided through the vdk-core configuration (seevdk config-helpfor more info)UsageRunpipinstallvdk-impalaAfter this, data jobs will have access to a Impala database connection, managed by Versatile Data Kit SDK.If it is the only database plugin installed , vdk would automatically use it.
Otherwise, users need to setVDK_DB_DEFAULT_TYPE=IMPALAas an environment variable or set 'db_default_type' option in the data job config file (config.ini).For exampledefrun(job_input:IJobInput):job_input.execute_query("select 'Hi Impala!'")LineageThe package can gather lineage data for all successful Impala SQL queries that have actually read or written data.
Other plugins can read and optionally send the lineage data to separate system.
They need to provide ILineageLogger implementation and hook this way:@hookimpldefvdk_initialize(context:CoreContext)->None:context.state.set(StoreKey[ILineageLogger]("impala-lineage-logger"),MyLogger())Lineage is calculated based on the executed query profile. It is retrieved via the cursor by executing additional RPC
request against the same Impala node that has coordinated the query right after the original query has successfully
finished. Seehttps://impala.apache.org/docs/build/html/topics/impala_logging.htmlfor more information how profiles are
stored and herehttps://impala.apache.org/docs/build/impala-3.1.pdffor more information about the profiles themselves.If enabled, query plan is retrieved for every successfully executed query against Impala excluding keepalive queries
like "Select 1".Database Loading TemplatesKimbal dimensional modeling templatesSCD1SCD2dimension tablesPeriodic Snapshot Fact TableInsertSee the followingtutorialfor more details. It is based on Trino but the process is equivalent for Impala (only the database configuration requires change).Data Quality ChecksMost of the processing templates support quality checks that are used for preventing bad data going into production tables.
The checks represent a callback function that is passed as an optional parameter to the job_input.execute_template() method.Example:defrun(job_input:IJobInput)->None:defcheck(tmp_table_name):result=#Implement your data quality check logic and return True/Falsereturnresultjob_input.execute_template(template_name="load/dimension/scd1","source_schema":test_schema,"source_view":source_view,"target_schema":test_schema,"target_table":target_table,"check":check,"staging_schema":staging_schema,#If not provided the checks would be performed in the target_schema)ConfigurationRun vdk config-help - search for those prefixed with "IMPALA_" to see what configuration options are available.DisclaimerThis plugin is tested against a specific impala version. The version comes from the docker-compose.yaml container's impala version. For more information on the imapala version tested against please google the docker image.TestingTesting this plugin locally requires installing the dependencies listed in vdk-plugins/vdk-impala/requirements.txtRunpipinstall-rrequirements.txt