Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

How to call hiveconf in perl programming.

How to call hiveconf in perl programming.

New Contributor

Dear Team,

 

Like shell script, how can we call hql using hiveconf in perl programming.

 

I want to insert data into the table passing perl variable.

 

Like in shell script : 

SOURCE=$1

AUDIT_DATE=$2

hive --hiveconf SOURCE="${SOURCE}" --hiveconf AUDIT_DATE="${AUDIT_DATE}" -S -f /CODEBASE/AUDIT/Mod_Audit_lodging.sql

Mod_Audit_lodging.sql : 

INSERT INTO  test.WORKFLOW_DETAILED_AUDIT_FILE PARTITION (AUDIT_DATE='${hiveconf:AUDIT_DATE}') SELECT TRIM(FILE_RECORD_COUNT),TRIM(FILENAME),TRIM(JOBNAME),TRIM(PROGRAM),TRIM(SOURCE),TRIM(BATCH_ID) FROM test.WORKFLOW_DETAILED_AUDIT_FILE_STG where trim(SOURCE)='${hiveconf:SOURCE}';

 

how can we implement same in perl programming ?

 

 

Kindly guide.

 

Regards

1 REPLY 1

Re: How to call hiveconf in perl programming.

Master Guru
Like most other languages, Perl offers a function to execute a command on the host OS: https://perldoc.perl.org/functions/system.html

You can use Perl to prepare your Hive CLI command lines / query text, and then execute the "hive" command with args from within via the `system(…)` call.
Don't have an account?
Coming from Hortonworks? Activate your account here