0
스파크 데이터 프레임/데이터 세트에서 엄격한 데이터 유형 확인을 사용하려면 어떻게해야합니까? 우리는 변형을 위해 업스트림 시스템에서 많은 시스템 생성 및 수동 공급을 받고 있습니다. 변환을 시작하기 전에 피드를 추출하고 스키마에 대해 엄격한 데이터 형식 검사를 수행하는 것이 좋습니다 Spark 2.0으로 얼마나 효율적으로 수행 할 수 있다고 제안 할 수 있습니까?
우리는 내가 좋아하는 뭔가를 할 수 있습니다 schema.You을 정의하는 케이스 클래스를 사용하면 스칼라를 사용하고 따라서 내 제안 것 같은데Spark Dataframe/Dataset에서 엄격한 데이터 유형 검사를 적용하는 방법?
1. User infereSchema = true, while reading file and get generated dataframes schema to validate against expected schema. Normally infereSchema= true is two phase operation, prove costly for give file
2. Enforcing schema while creating data frame from csv file
val df:DataFrame = spark.read.format("csv")
.schema(readSchemaFromAvroSchemaFile)
.option("header","true")
.option("inferSchema","false")
.csv("CSVFileUri")
strict data type check not imposed while writing,
it applied only while reading dataframe
Is it possible to validate without making read call as it could be expensive operation?
Also in case of double type show some strange behavior
if we have avro schema
{
"namespace":"com.test.schema.validation",
"name" : "example",
"type" : "record",
"fields" [
{"name":"item_id","type":["null","string"],"default":null},
{"name":"item_price","type":["null","double"],"default":null}
]
}
CSV file
item_id|item_price
1|234.90
2|634.90
3|534.90
4|233A40.90
5|233E12
df.show(10)- gives me following
item_id|item_price
1|234.90
2|634.90
3|534.90
4|233.90
5|2.3E13
Value is Row#4 truncated without any failure so it's hard catch
Please suggest if you have any efficient way to validate schema
Have you come across double type value truncation?
감사합니다. @Akhilanand 사례 클래스로 스키마를 적용하고 있습니다. – user1876321