spark — dataset → DataFrame + write helpers (requires Spark)
Method | Purpose |
|---|---|
| Read dataset into a DataFrame |
| True if Hive table exists |
| Create Hive table from DataFrame |
| Write a DataFrame to an event store. Auto-creates the dataset if it doesn't exist. |
| Convenience wrapper around |
| Push a local file into the event store |
Python
df = synutils.spark.createDataFrame("user_events")
df.show(5)
synutils.spark.writeDatasetToEventStore(df, "user_events")Scala
val df = synutils.spark.createDataFrame("user_events")
df.show(5)
synutils.spark.writeDatasetToEventStore(df, "user_events")writeToEventStore — full signature
Writes a DataFrame to a Hive-managed event store table. If the dataset doesn't already exist in the platform's metadata, it is created on the fly using the supplied fileFormat. Partitioning, compression, and process-mode handling are derived from the dataset definition; this method only orchestrates the Spark-side write.
Parameter | Type | Default | Purpose |
|---|---|---|---|
| DataFrame | — | Source DataFrame to write |
| String | — | Dataset name in |
| Int |
| If > 0 and the dataset is partitioned, adds |
| String |
| Override the dataset's configured partition column. If set, the dataset is updated to partition by this column before writing |
| Boolean |
|
|
| Boolean |
| When |
| FileFormat / String |
| Used only when the dataset must be created (404 from the dataset API). Ignored if the dataset already exists. Supported: |
Python
from synutils.file_format import FileFormat # Minimal write — dataset must already exist synutils.spark.writeToEventStore(df, "analytics.user_events") # Append (don't overwrite existing partitions) synutils.spark.writeToEventStore(df, "analytics.user_events", isOverwrite=False) # Control output file count per partition (e.g. 8 files per partition) synutils.spark.writeToEventStore(df, "analytics.user_events", numPartitions=8) # Override the partition column for this write only synutils.spark.writeToEventStore(df, "analytics.user_events", partitionedDateColumn="event_date") # Auto-create as Avro if dataset doesn't exist yet synutils.spark.writeToEventStore(df, "analytics.new_avro_dataset", fileFormat=FileFormat.AVRO) # Preserve existing table definition (don't recreate) synutils.spark.writeToEventStore(df, "analytics.user_events", overrideProcessMode=False)
Scala
import com.syntasa.synutils.FileFormat // Minimal write synutils.spark.writeToEventStore(df, "analytics.user_events") // Append synutils.spark.writeToEventStore(df, "analytics.user_events", isOverwrite = false) // Control output file count per partition synutils.spark.writeToEventStore(df, "analytics.user_events", numPartitions = 8) // Override partition column for this write synutils.spark.writeToEventStore(df, "analytics.user_events", partitionedDateColumn = "event_date") // Auto-create as Avro synutils.spark.writeToEventStore(df, "analytics.new_avro_dataset", fileFormat = FileFormat.AVRO.getValue()) // Preserve existing table definition synutils.spark.writeToEventStore(df, "analytics.user_events", overrideProcessMode = false)
Heads-up:
isOverwrite=Trueoverwrites at the partition level for partitioned tables, not the entire table. For non-partitioned tables it overwrites the whole table.