You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
scala> import org.apache.spark.sql.{SparkSession, Row}
import org.apache.spark.sql.{SparkSession, Row}
scala> import org.apache.spark.sql.functions._
import org.apache.spark.sql.functions._
scala> import org.apache.spark.sql.types._
import org.apache.spark.sql.types._
scala>
scala> val spark = SparkSession.builder.appName("Test").getOrCreate()
24/05/28 07:45:26 WARN Utils: Service 'SparkUI' could not bind on port 4040. Attempting port 4041.
24/05/28 07:45:26 WARN RapidsPluginUtils: RAPIDS Accelerator is enabled, to disable GPU support set `spark.rapids.sql.enabled` to false.
24/05/28 07:45:26 WARN RapidsPluginUtils: spark.rapids.sql.explain is set to `ALL`. Set it to 'NONE' to suppress the diagnostics logging about the query placement on the GPU.
spark: org.apache.spark.sql.SparkSession = org.apache.spark.sql.SparkSession@64a97889
scala> import spark.implicits._
import spark.implicits._
scala> val input = """{
| | "a": 1,
| | "c": "foo"
| |}
| |""".stripMargin
input: String =
"{
"a": 1,
"c": "foo"
}
"
scala> val jsonSchema = new StructType().add("a", LongType, nullable = false).add("b", StringType, nullable = false).add("c", StringType, nullable = false)
jsonSchema: org.apache.spark.sql.types.StructType = StructType(StructField(a,LongType,false),StructField(b,StringType,false),StructField(c,StringType,false))
scala> val jsonData = Seq(input).toDS()
jsonData: org.apache.spark.sql.Dataset[String] = [value: string]
scala> val df = jsonData.toDF("jsonString")
df: org.apache.spark.sql.DataFrame = [jsonString: string]
scala>
scala> df.write.mode("OVERWRITE").parquet("TEMP")
24/05/28 07:45:29 WARN GpuOverrides:
*Exec <DataWritingCommandExec> will run on GPU
*Output <InsertIntoHadoopFsRelationCommand> will run on GPU
! <LocalTableScanExec> cannot run on GPU because GPU does not currently support the operator class org.apache.spark.sql.execution.LocalTableScanExec
@Expression <AttributeReference> jsonString#93 could run on GPU
scala> val df2 = spark.read.parquet("TEMP")
df2: org.apache.spark.sql.DataFrame = [jsonString: string]
scala> val parsedDF = df2.select(from_json(col("jsonString"), jsonSchema).as("data"))
parsedDF: org.apache.spark.sql.DataFrame = [data: struct<a: bigint, b: string ... 1 more field>]
scala> .select("data.*")
res20: org.apache.spark.sql.DataFrame = [a: bigint, b: string ... 1 more field]
scala> parsedDF.show(false)
24/05/28 07:45:29 WARN GpuOverrides:
!Exec <CollectLimitExec> cannot run on GPU because the Exec CollectLimitExec has been disabled, and is disabled by default because Collect Limit replacement can be slower on the GPU, if huge number of rows in a batch it could help by limiting the number of rows transferred from GPU to CPU. Set spark.rapids.sql.exec.CollectLimitExec to true if you wish to enable it
@Partitioning <SinglePartition$> could run on GPU
*Exec <ProjectExec> will run on GPU
*Expression <Alias> cast(from_json(StructField(a,LongType,false), StructField(b,StringType,false), StructField(c,StringType,false), jsonString#96, Some(UTC)) as string) AS data#108 will run on GPU
*Expression <Cast> cast(from_json(StructField(a,LongType,false), StructField(b,StringType,false), StructField(c,StringType,false), jsonString#96, Some(UTC)) as string) will run on GPU
*Expression <JsonToStructs> from_json(StructField(a,LongType,false), StructField(b,StringType,false), StructField(c,StringType,false), jsonString#96, Some(UTC)) will run on GPU
*Exec <FileSourceScanExec> will run on GPU
24/05/28 07:45:29 ERROR Executor: Exception in task 0.0 in stage 3.0 (TID 3)
java.lang.IllegalArgumentException: We cannot currently support parsing JSON that contains a line separator in it
at org.apache.spark.sql.rapids.GpuJsonToStructs.$anonfun$checkForNewline$3(GpuJsonToStructs.scala:144)
at org.apache.spark.sql.rapids.GpuJsonToStructs.$anonfun$checkForNewline$3$adapted(GpuJsonToStructs.scala:141)
at com.nvidia.spark.rapids.Arm$.withResource(Arm.scala:30)
at org.apache.spark.sql.rapids.GpuJsonToStructs.$anonfun$checkForNewline$2(GpuJsonToStructs.scala:141)
at org.apache.spark.sql.rapids.GpuJsonToStructs.$anonfun$checkForNewline$2$adapted(GpuJsonToStructs.scala:140)
at com.nvidia.spark.rapids.Arm$.withResource(Arm.scala:30)
at org.apache.spark.sql.rapids.GpuJsonToStructs.$anonfun$checkForNewline$1(GpuJsonToStructs.scala:140)
at org.apache.spark.sql.rapids.GpuJsonToStructs.$anonfun$checkForNewline$1$adapted(GpuJsonToStructs.scala:139)
at com.nvidia.spark.rapids.Arm$.withResource(Arm.scala:30)
at org.apache.spark.sql.rapids.GpuJsonToStructs.checkForNewline(GpuJsonToStructs.scala:139)
at org.apache.spark.sql.rapids.GpuJsonToStructs.$anonfun$cleanAndConcat$12(GpuJsonToStructs.scala:116)
at com.nvidia.spark.rapids.Arm$.withResource(Arm.scala:30)
at org.apache.spark.sql.rapids.GpuJsonToStructs.$anonfun$cleanAndConcat$11(GpuJsonToStructs.scala:115)
at com.nvidia.spark.rapids.Arm$.withResource(Arm.scala:30)
The text was updated successfully, but these errors were encountered:
Feng-Jiang28
changed the title
from_json missing fields
from_json with predefined schema when converts json with misssing fields, throwing an exception.
May 28, 2024
GaryShen2008
changed the title
from_json with predefined schema when converts json with misssing fields, throwing an exception.
from_json with predefined schema when converts json with missing fields, throwing an exception.
Jun 7, 2024
revans2
changed the title
from_json with predefined schema when converts json with missing fields, throwing an exception.
from_json cannot support line separator in the input string.
Sep 17, 2024
from_json when there is a new line/line separator in the input results in an exception being thrown.
Reproduce:
CPU:
GPU:
The text was updated successfully, but these errors were encountered: