Skip to content
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

Closed
wants to merge 1 commit into from
Closed

Conversation

changli6
Copy link
Contributor

No description provided.

}
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);
Copy link

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?

Copy link
Contributor Author

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);
}
Copy link

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

Copy link
Contributor Author

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" +
Copy link

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

@changli6
Copy link
Contributor Author

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.

@changli6 changli6 closed this Jul 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

8 participants