nsivabalan commented on issue #5233:
URL: https://github.com/apache/hudi/issues/5233#issuecomment-1125413411
I could not reproduce. I used our quick start to try this out
```
import org.apache.hudi.QuickstartUtils._
import scala.collection.JavaConversions._
import org.apache.spark.sql.SaveMode._
import org.apache.hudi.DataSourceReadOptions._
import org.apache.hudi.DataSourceWriteOptions._
import org.apache.hudi.config.HoodieWriteConfig._
val tableName = "hudi_trips_cow"
val basePath = "file:///tmp/hudi_trips_cow"
val dataGen = new DataGenerator
// spark-shell
val inserts = convertToStringList(dataGen.generateInserts(10))
val df = spark.read.json(spark.sparkContext.parallelize(inserts, 2))
df.write.format("hudi").
options(getQuickstartWriteConfigs).
option(PRECOMBINE_FIELD_OPT_KEY, "ts").
option(RECORDKEY_FIELD_OPT_KEY, "uuid").
option(PARTITIONPATH_FIELD_OPT_KEY, "partitionpath").
option(TABLE_NAME, tableName).
mode(Overwrite).
save(basePath)
val tripsSnapshotDF = spark.
read.
format("hudi").
load(basePath)
tripsSnapshotDF.createOrReplaceTempView("hudi_trips_snapshot")
spark.sql("select fare, begin_lon, begin_lat, ts from hudi_trips_snapshot
where fare > 20.0").show()
spark.sql("select count(*) from hudi_trips_snapshot").show
val updates = convertToStringList(dataGen.generateUpdates(5))
val df = spark.read.json(spark.sparkContext.parallelize(updates, 2))
import org.apache.spark.sql.types.DataTypes;
val df1 = df.withColumn("_hoodie_is_deleted",
org.apache.spark.sql.functions.lit(true).cast(DataTypes.BooleanType))
import org.apache.spark.sql.types.StructType;
import org.apache.spark.sql.types.StructField;
val schema = StructType( Seq (
| StructField( "begin_lat", DoubleType, true),
| StructField( "begin_lon", DoubleType, true),
| StructField( "driver", StringType, true),
| StructField( "end_lat", DoubleType, true),
| StructField( "end_lon", DoubleType, true),
| StructField( "fare", DoubleType, true),
| StructField( "partitionpath", StringType, true),
| StructField( "rider", StringType, true),
| StructField( "ts", LongType, true),
| StructField( "uuid", StringType, true),
| StructField( "_hoodie_is_deleted", BooleanType, true)
| ))
val df2 = spark.sqlContext.createDataFrame(df1.rdd, schema)
df2.printSchema
// ensure hoodie_is_deleted is nullable
df2.write.format("hudi").
options(getQuickstartWriteConfigs).
option(PRECOMBINE_FIELD_OPT_KEY, "ts").
option(RECORDKEY_FIELD_OPT_KEY, "uuid").
option(PARTITIONPATH_FIELD_OPT_KEY, "partitionpath").
option(TABLE_NAME, tableName).
mode(Append).
save(basePath)
val tripsSnapshotDF = spark.
read.
format("hudi").
load(basePath)
tripsSnapshotDF.createOrReplaceTempView("hudi_trips_snapshot")
spark.sql("select fare, begin_lon, begin_lat, ts, _hoodie_is_deleted from
hudi_trips_snapshot where fare > 20.0").show()
spark.sql("select count(*) from hudi_trips_snapshot").show
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]