zhengruifeng opened a new pull request, #40535:
URL: https://github.com/apache/spark/pull/40535

   ### What changes were proposed in this pull request?
    Implement Avro functions
   
   
   ### Why are the changes needed?
   For function parity
   
   
   ### Does this PR introduce _any_ user-facing change?
   yes, new APIs
   
   
   ### How was this patch tested?
   added doctest and manually check
   ```
   (spark_dev) ➜  spark git:(connect_avro_functions) ✗ bin/pyspark --remote 
"local[*]" --jars 
connector/avro/target/scala-2.12/spark-avro_2.12-3.5.0-SNAPSHOT.jar
   Python 3.9.16 (main, Mar  8 2023, 04:29:24) 
   Type 'copyright', 'credits' or 'license' for more information
   IPython 8.11.0 -- An enhanced Interactive Python. Type '?' for help.
   23/03/23 16:28:50 WARN NativeCodeLoader: Unable to load native-hadoop 
library for your platform... using builtin-java classes where applicable
   Setting default log level to "WARN".
   To adjust logging level use sc.setLogLevel(newLevel). For SparkR, use 
setLogLevel(newLevel).
   Welcome to
         ____              __
        / __/__  ___ _____/ /__
       _\ \/ _ \/ _ `/ __/  '_/
      /__ / .__/\_,_/_/ /_/\_\   version 3.5.0.dev0
         /_/
   
   Using Python version 3.9.16 (main, Mar  8 2023 04:29:24)
   Client connected to the Spark Connect server at localhost
   SparkSession available as 'spark'.
   
   In [1]:     >>> from pyspark.sql import Row
      ...:     >>> from pyspark.sql.avro.functions import from_avro, to_avro
      ...:     >>> data = [(1, Row(age=2, name='Alice'))]
      ...:     >>> df = spark.createDataFrame(data, ("key", "value"))
      ...:     >>> avroDf = df.select(to_avro(df.value).alias("avro"))
   
   In [2]: avroDf.collect()
   Out[2]: [Row(avro=bytearray(b'\x00\x00\x04\x00\nAlice'))]
   ```


-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to