Using the following code in Spark(Java), we save dataframe in Oracle, it creates a table too if doesn't exists.
Dataset<Row> someAccountDF = sparkSession.createDataFrame(impalaAccountsDF.toJavaRDD(), AccountSchema.getSchema());
dataFrame.write().mode(saveMode).jdbc(connectionUrl, tableName, connectionParams);
Now it creates columns with double quotes like-
CREATE TABLE "SCHEMA"."ACCOUNT"
( "primaryidentifier" VARCHAR2(255 BYTE),
"systemdata" VARCHAR2(255 BYTE), ......
)
So when I query
select primaryidentifier from account;
//Doesn't work
but when I query
select "primaryidentifier" from account;
//Works
but it creates issues in our code in mapping etc. and also doesn't look good having double quotes in columnname.
Out SchemaClass is like below. I would like to have something like Varchar2 instead of StringType:
public class AccountSchema {
public StructType getSchema() {
StructType schemaTyped = new StructType()
.add("primaryidentifier", StringType)
.add("systemdata", StringType)
.............}
}
I saw this question but unable to follow it (I'm know very little bit Scala)