Hi @balaji.ramaswamy ,
I am trying to follow create jdbc connection with Dremio using spark . In which I am reading from RDBMS and writing to S3. For that I have already added our s3 as data source with below options.
However, When I am trying to write back to data. Below is my code
package com.example.dremio.spark;
import org.apache.spark.sql.Dataset;
import org.apache.spark.sql.Row;
import org.apache.spark.sql.SparkSession;
import org.apache.spark.sql.functions;
public class SparkExample {
static Dataset<Row> processDf(Dataset<Row> orderDetails, Dataset<Row> products,Dataset<Row> orders){
orders = orders.withColumn("DAY_OF_WEEK",functions.date_format(functions.col("orderDate"),"E")).filter(functions.col("DAY_OF_WEEK").equalTo("Mon"));
Dataset<Row> order_orderDetails = orders.join(orderDetails,orders.col("orderNumber").equalTo(orderDetails.col("orderNumber")),"inner");
return order_orderDetails.join(products,order_orderDetails.col("productCode").equalTo(products.col("productCode")));
}
public static void main(String[] args) throws ClassNotFoundException {
SparkSession spark = SparkSession.builder()
.appName("Dremio-Spark example")
.master("local[*]")
.getOrCreate();
Dataset<Row> orderDetails = spark.read().format("jdbc").option("driver","com.dremio.jdbc.Driver").option("url", "jdbc:dremio:direct=127.0.0.1:31857").option("dbtable", "mysqldev.classicmodels.orderdetails").option("user", "ayush.goyal").option("password", "mypassword").load();
orderDetails.createOrReplaceGlobalTempView("orderDetails");
Dataset<Row> products = spark.read()
.format("jdbc")
.option("driver","com.dremio.jdbc.Driver")
.option("url", "jdbc:dremio:direct=127.0.0.1:31857")
.option("dbtable", "mysqldev.classicmodels.products")
.option("user", "ayush.goyal")
.option("password", "mypassword")
.load();
Dataset<Row> orders = spark.read()
.format("jdbc")
.option("driver","com.dremio.jdbc.Driver")
.option("url", "jdbc:dremio:direct=127.0.0.1:31857")
.option("dbtable", "mysqldev.classicmodels.orders")
.option("user", "ayush.goyal")
.option("password", "mypassword")
.load();
Dataset<Row> df = processDf(orderDetails,products,orders);
df.show();
df.write().format("jdbc").option("driver","com.dremio.jdbc.Driver").option("url","jdbc:dremio:direct=127.0.0.1:31857").option("dbtable","\"minio-dev\".dremio.result").option("user","ayush.goyal").option("password","mypassword").save();
}
}
With this code I am to read the data but unable to write because Dremio interpreting this incorrectly. for that I have attached the profile.
ac3a7993-131c-4fad-bbee-5452ea7cc240.zip (5.7 KB)
Thanks