Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit 978c0cd

Browse files
added ability to not infer schema
1 parent f79e3cf commit 978c0cd

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ https://www.audienceproject.com/blog/tech/sparkdynamodb-using-aws-dynamodb-data-
66

77
## News
88

9+
* 2021-01-28: Added option `inferSchema=false` which is useful when writing to a table with many columns
910
* 2020-07-23: Releasing version 1.1.0 which supports Spark 3.0.0 and Scala 2.12. Future releases will no longer be compatible with Scala 2.11 and Spark 2.x.x.
1011
* 2020-04-28: Releasing version 1.0.4. Includes support for assuming AWS roles through custom STS endpoint (credits @jhulten).
1112
* 2020-04-09: We are releasing version 1.0.3 of the Spark+DynamoDB connector. Added option to `delete` records (thank you @rhelmstetter). Fixes (thank you @juanyunism for #46).
@@ -100,6 +101,7 @@ The following parameters can be set as options on the Spark writer object before
100101
- `targetCapacity` fraction of provisioned write capacity on the table to consume for writing or updating. Default 1 (i.e. 100% capacity).
101102
- `update` if true items will be written using UpdateItem on keys rather than BatchWriteItem. Default false.
102103
- `throughput` the desired write throughput to use. It overwrites any calculation used by the package. It is intended to be used with tables that are on-demand. Defaults to 100 for on-demand.
104+
- `inferSchema` if false will not automatically infer schema - this is useful when writing to a table with many columns
103105

104106
## System Properties
105107
The following Java system properties are available for configuration.

src/main/scala/com/audienceproject/spark/dynamodb/datasource/DynamoTable.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class DynamoTable(options: CaseInsensitiveStringMap,
8080

8181
private def inferSchema(): StructType = {
8282
val inferenceItems =
83-
if (dynamoConnector.nonEmpty) dynamoConnector.scan(0, Seq.empty, Seq.empty).firstPage().getLowLevelResult.getItems.asScala
83+
if (dynamoConnector.nonEmpty && options.getBoolean("inferSchema",true)) dynamoConnector.scan(0, Seq.empty, Seq.empty).firstPage().getLowLevelResult.getItems.asScala
8484
else Seq.empty
8585

8686
val typeMapping = inferenceItems.foldLeft(Map[String, DataType]())({

0 commit comments

Comments
 (0)