-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DB-6045 Support compression for avro external table #2065
Conversation
} | ||
else if (storedAs.toLowerCase().equals("a")) { | ||
empty.write().partitionBy(partitionByCols.toArray(new String[partitionByCols.size()])) | ||
.mode(SaveMode.Append).format("com.databricks.spark.avro").save(location); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why option("compression", compression) does not work for avro?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried but not work.
In the Spark-Avro doc (https://docs.databricks.com/spark/latest/data-sources/read-avro.html), the example showed the compression code was accepted by spark conf settting.
You can also specify Avro compression options:
Copy to clipboardCopy
import com.databricks.spark.avro._
// configuration to use deflate compression
spark.conf.set("spark.sql.avro.compression.codec", "deflate")
Others raised the same confusion of compression code setting, but was not responded.
(databricks/spark-avro#259)
if (compression.toLowerCase().equals("zlib")) | ||
compression = "deflate"; | ||
spliceSpark.conf().set("spark.sql.avro.compression.codec",compression); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spark session and configuration is shared by all spark jobs. If two "create external table" are being executed, and one wants to compress avro file, the other does not, or they try to compress in different format, setting a global configuration may not work
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @jyuanca Global session is improper, let me address it.
int insertCount = methodWatcher.executeUpdate(String.format("insert into compressed_zlib_avro_test values ('XXXX')," + | ||
"('YYYY')")); | ||
Assert.assertEquals("insertCount is wrong",2,insertCount); | ||
ResultSet rs = methodWatcher.executeQuery("select * from compressed_zlib_avro_test"); | ||
Assert.assertEquals("COL1 |\n" + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test cannot tell whether the table is compressed
Global session level setting of Avro compression may impact other Avro-related spark jobs, and spark-avro doesn't support DataFrame level setting for compression so far, we have to defer this feature until Spark implemented the DataFrame level setting for Avro file. |
No description provided.