Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-yuwang committed Sep 27, 2024
1 parent a046486 commit d713e61
Showing 1 changed file with 6 additions and 17 deletions.
23 changes: 6 additions & 17 deletions src/main/scala/net/snowflake/spark/snowflake/SnowflakeWriter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -104,24 +104,9 @@ private[snowflake] class SnowflakeWriter(jdbcWrapper: JDBCWrapper) {
}
}
} finally conn.close()
} else if (params.columnMap.isEmpty && params.useParquetInWrite() &&
jdbcWrapper.tableExists(params, params.table.get.name)){
val conn = jdbcWrapper.getConnector(params)
try {
val toSchema = Utils.removeQuote(
jdbcWrapper.resolveTable(conn, params.table.get.name, params)
)
data.schema.zip(toSchema).foreach{
case (field1, field2) =>
if (field1.name.toUpperCase != field2.name.toUpperCase){
throw new IllegalArgumentException(
s"Column with name ${field1.name} does not match column name in snowflake table")
}
}
} finally conn.close()
}

if (params.useParquetInWrite() && saveMode != SaveMode.Overwrite){
if (params.useParquetInWrite()){
val conn = jdbcWrapper.getConnector(params)
try{
if (jdbcWrapper.tableExists(params, params.table.get.name)){
Expand Down Expand Up @@ -161,7 +146,11 @@ private[snowflake] class SnowflakeWriter(jdbcWrapper: JDBCWrapper) {
)
})
case _ =>
val newSchema = snowflakeStyleSchema(schema, params)
val newSchema = if (params.snowflakeTableSchema.isEmpty) {
snowflakeStyleSchema(schema, params)
} else {
params.snowflakeTableSchema
}
StructType(newSchema.map {
case StructField(name, dataType, nullable, metadata) =>
StructField(
Expand Down

0 comments on commit d713e61

Please sign in to comment.