What is the way to connect to hive using scala code and execute query into hive? - scala

I checked out this link but did not find anything useful :
HiveClient Documentation

From raw Scala you can use Hive JDBC connector: https://cwiki.apache.org/confluence/display/Hive/HiveServer2+Clients#HiveServer2Clients-JDBC.
One more option is to use Spark Hive context.

Related

kafka-connect JDBC PostgreSQL Sink Connector explicitly define the PostgrSQL schema (namespace)

I am using the JDBC sink connector to write data to postgresql.
The connector works fine, but it seems the connector can only write data to the default postgresql schema called public
This is the common JDBC URL format for postgresql.
jdbc:postgresql://<host>:<port5432>/<database>
Is it possible to explicitly define the schema name, to which I need the postgresql sink connector to write?
UPDATE:
Thanks, #Laurenz Albe for the hint. I can define search_path in the jdbc connection URL like either of these:
jdbc:postgresql://<host>:<port>/<database>?options=-c%20search_path=myschema,public
jdbc:postgresql://<host>:<port>/<database>?currentSchema=myschema
Use the options connection parameter to set the search_path:
jdbc:postgresql://<host>:<port5432>/<database>?options=-c%20search_path=myschema,public

How I can connect to snowflake using scala slick jdbc

I am using scala and akka stream for my application and finally want to insert the record to snowflake.
Is it possible to connect to snowflake using slick jdbc or alpakka slick .
Please assist
You can't, Snowflake is not in the list of supported databases:
https://scala-slick.org/doc/3.3.2/supported-databases.html

Spark SQL build for hive?

I have downloaded spark release - 1.3.1 and package type is Pre-build for Hadoop 2.6 and later
now i want to run below scala code using spark shell so i followed this steps
1. bin/spark-shell
2. val sqlContext = new org.apache.spark.sql.hive.HiveContext(sc)
3. sqlContext.sql("CREATE TABLE IF NOT EXISTS src (key INT, value STRING)")
Now the problem is if i verity it on hue browser like
select * from src;
then i get
table not found exception
that means table not created how do i configure hive with spark shell to make this successful. i want to use SparkSQL also i need to read and write data from hive.
i randomly heard that we need to copy hive-site.xml file somewhere in spark directory
can someone please explain me with the steps - SparkSQL and Hive configuration
Thanks
Tushar
Indeed, the hive-site.xml direction is correct. Take a look at https://spark.apache.org/docs/latest/sql-programming-guide.html#hive-tables .
Also it sounds like you wish to create a hive table from spark, for that look at "Saving to Persistent Tables" in the same document as above.

Connect icCube with Reshift

in icCube 5.1 there is no Redshift as list of supported JDBC connections.
How to create a data source in icCube on Amazon Redshift ?
A first solution is using the Postgres jdbc driver. Redshift is based on Postgres so it also works (for how long is a good question).
The second is a bit more complicated as you need to add Reshift jdbc driver to icCube. First download jdbc driver from amazon from here, after follow this instructions to add a library to icCube.
Once done you've to configure a new data-source :

Synchronizing data between Hadoop and PostgreSql using SymmetricDs

I'm using Hadoop to store the data of our application. How can I synchronize data between PostgreSql and Hadoop? I 'm using SymmetricDS as the replication tool.
If hadoop only copies data from PostgreSQL and no updates are done on the hadoop site, try using sqoop - simple database into hadoop import tool.
If you want to continue to use SymmetricDS you can implement an IDatabaseWriter. Here is an example of writing to MongoDB. https://github.com/JumpMind/symmetric-mongo