Pergunta

I am using WSO2 ESB 4.5.1 and WSO2 BAM 2.0.0. In my Hive script I am attempting to get a single value and assign it to a variable so I can later use it in SQL statements. I can use a variable using hiveconf but I'm not sure how to assign a single value from result set to it. any ideas? Thanks.

Foi útil?

Solução

You can extend the AbstractHiveAnalyzer and write you own class which executes the query and set the hive conf value, similar to this summarizer. Here you can see the execute() method should be implemented and this will be called by BAM. Here you can add your preferred query and assign the hive conf with 'setProperty("your_hive_conf", yourResult.string());'.

You can build your java application as typical '.jar' file or osgi bundle. If you have packaged as just a '.jar' file, then you should place the jar in $BAM_HOME/repository/components/lib. If you packaged the application as osgi bundle, then place the file in $BAM_HOME/repository/components/dropins folder. And restart BAM server.

And finally in your hive script that you add in BAM, you should include you extended class as 'class your.package.name.HiveAnalyzerImpl;', so that BAM will run the execute() method which you have implemented in your class and your hive conf will be set. And then, value you have set for your hive conf can be used in the hive script as ${hiveconf:your_hive_conf}.

Hope this helps.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top