JustFeng opened a new issue, #6984:
URL: https://github.com/apache/kyuubi/issues/6984

   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of 
Conduct](https://www.apache.org/foundation/policies/conduct)
   
   
   ### Search before asking
   
   - [x] I have searched in the 
[issues](https://github.com/apache/kyuubi/issues?q=is%3Aissue) and found no 
similar issues.
   
   
   ### Describe the bug
   
   
   
   ### Issue Report: ValueError Occurs When Rendering Map Type Data Using 
%table Magic Command in Kyuubi
   
   ---
   
   #### **Title**  
   `ValueError: too many values to unpack (expected 2)` When Rendering Map-Type 
Data with `%table` Magic Command
   
   ---
   
   #### **Description**  
   When using the Kyuubi magic command `%table` to display query results 
containing **Map-type data**, a `ValueError` is thrown during the rendering 
process. The error indicates that an attempt was made to unpack more values 
than expected.
   
   ---
   
   #### **Steps to Reproduce**  
   1. **Execute a Query Returning Map-Type Data**:  
      Run a Kyuubi SQL query that involves a `MAP<KEY, VALUE>` column.  
      Example:  
      ```python
       from pyspark.sql import SparkSession
       from pyspark.sql.types import MapType, StringType, IntegerType
       spark = SparkSession.builder \
           .appName("MapFieldExample") \
           .getOrCreate()
   
       data = [
           (1, {"a": "1", "b": "2"}),     
           (2, {"x": "10"}),
           (3, {"key": "value"})
       ]
   
       schema = "id INT, map_col MAP<STRING, STRING>"
       df = spark.createDataFrame(data, schema=schema)
       df.printSchema()
       df2=df.collect()
      ```
   
   2. **Trigger Rendering with `%table`**:  
      Use the `%table` magic command to render the result:  
      ```python
      %table df2
      ```
   
   3. **Observe the Error**:  
      The error occurs during column data processing, specifically when 
iterating over Map entries.
   
   ---
   
   #### **Expected Result**  
   The `%table` command should render all columns, including Map-type data 
   ```text
   {'application/vnd.livy.table.v1+json': {'headers': [{'name': 'id', 'type': 
'INT_TYPE'}, {'name': 'map_col', 'type': 'MAP_TYPE'}], 'data': [[1, {'a': '1', 
'b': '2'}], [2, {'x': '10'}], [3, {'key': 'value'}]]}}
   ```
   
   ---
   
   #### **Actual Result**  
   ```python
   ValueError: too many values to unpack (expected 2)
   ```
   ---
   
   #### **Environment Details**  
   - **Kyuubi Server Version**:1.10.0
   - **Client Environment**:
     - Notebooks: Jupyter
     - Python Version :3.9.13 
   - **Database & Dependencies**:  
     - Spark Version: 3.5.1.1
   
   ---
   
   ### Affects Version(s)
   
   1.9
   
   ### Kyuubi Server Log Output
   
   ```logtalk
   
   ```
   
   ### Kyuubi Engine Log Output
   
   ```logtalk
   
   ```
   
   ### Kyuubi Server Configurations
   
   ```yaml
   
   ```
   
   ### Kyuubi Engine Configurations
   
   ```yaml
   
   ```
   
   ### Additional context
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [x] Yes. I would be willing to submit a PR with guidance from the Kyuubi 
community to fix.
   - [ ] No. I cannot submit a PR at this time.


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