This is an automated email from the ASF dual-hosted git repository.

maxgekk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/master by this push:
     new ff93cbb0c4b4 [SPARK-52634][SQL][DOCS] Update the ANSI compliance page 
regarding the TIME type
ff93cbb0c4b4 is described below

commit ff93cbb0c4b49f4d8beae9cb9b8feac111883a97
Author: Max Gekk <max.g...@gmail.com>
AuthorDate: Fri Jul 4 13:18:29 2025 +0200

    [SPARK-52634][SQL][DOCS] Update the ANSI compliance page regarding the TIME 
type
    
    ### What changes were proposed in this pull request?
    In the PR, I propose to update the doc page 
https://spark.apache.org/docs/latest/sql-ref-ansi-compliance.html#cast 
regarding the TIME data type. After the update, the page looks like:
    <img width="947" alt="Screenshot 2025-07-04 at 10 32 51" 
src="https://github.com/user-attachments/assets/f3f55e95-a883-4ae5-bfe5-5f7b72d88350";
 />
    
    Store assignment rules:
    <img width="953" alt="Screenshot 2025-07-04 at 10 33 13" 
src="https://github.com/user-attachments/assets/6a3f4da2-a9b2-4709-9eaf-d516e000a8b8";
 />
    
    ### Why are the changes needed?
    To provide actual information about the TIME data type to Spark SQL users.
    
    ### Does this PR introduce _any_ user-facing change?
    No.
    
    ### How was this patch tested?
    Manually by building and checking the page:
    ```
    $ SKIP_API=1 bundle exec jekyll serve --watch
    ```
    
    ### Was this patch authored or co-authored using generative AI tooling?
    No.
    
    Closes #51333 from MaxGekk/time-cast-doc.
    
    Authored-by: Max Gekk <max.g...@gmail.com>
    Signed-off-by: Max Gekk <max.g...@gmail.com>
---
 docs/sql-ref-ansi-compliance.md | 55 ++++++++++++++++++++++-------------------
 1 file changed, 29 insertions(+), 26 deletions(-)

diff --git a/docs/sql-ref-ansi-compliance.md b/docs/sql-ref-ansi-compliance.md
index acef717ef40a..743f9ae6d12e 100644
--- a/docs/sql-ref-ansi-compliance.md
+++ b/docs/sql-ref-ansi-compliance.md
@@ -110,19 +110,20 @@ Besides, the ANSI SQL mode disallows the following type 
conversions which are al
  The valid combinations of source and target data type in a `CAST` expression 
are given by the following table.
 ā€œYā€ indicates that the combination is syntactically valid without restriction 
and ā€œNā€ indicates that the combination is not valid.
 
-| Source\Target | Numeric                              | String                
               | Date                                 | Timestamp               
             | Timestamp_NTZ                        | Interval                  
           | Boolean                              | Binary | Array              
                  | Map                                  | Struct               
                |
-|---------------|--------------------------------------|--------------------------------------|--------------------------------------|--------------------------------------|--------------------------------------|--------------------------------------|--------------------------------------|--------|--------------------------------------|--------------------------------------|--------------------------------------|
-| Numeric       | <span style="color:red">**Y**</span> | <span 
style="color:red">**Y**</span> | N                                    | <span 
style="color:red">**Y**</span> | N                                    | <span 
style="color:red">**Y**</span> | Y                                    | N      
| N                                    | N                                    | 
N                                    |
-| String        | <span style="color:red">**Y**</span> | Y                     
               | <span style="color:red">**Y**</span> | <span 
style="color:red">**Y**</span> | <span style="color:red">**Y**</span> | <span 
style="color:red">**Y**</span> | <span style="color:red">**Y**</span> | Y      
| N                                    | N                                    | 
N                                    |
-| Date          | N                                    | Y                     
               | Y                                    | Y                       
             | Y                                    | N                         
           | N                                    | N      | N                  
                  | N                                    | N                    
                |
-| Timestamp     | <span style="color:red">**Y**</span> | Y                     
               | Y                                    | Y                       
             | Y                                    | N                         
           | N                                    | N      | N                  
                  | N                                    | N                    
                |
-| Timestamp_NTZ | N                                    | Y                     
               | Y                                    | Y                       
             | Y                                    | N                         
           | N                                    | N      | N                  
                  | N                                    | N                    
                |
-| Interval      | <span style="color:red">**Y**</span> | Y                     
               | N                                    | N                       
             | N                                    | Y                         
           | N                                    | N      | N                  
                  | N                                    | N                    
                |
-| Boolean       | Y                                    | Y                     
               | N                                    | N                       
             | N                                    | N                         
           | Y                                    | N      | N                  
                  | N                                    | N                    
                |
-| Binary        | N                                    | Y                     
               | N                                    | N                       
             | N                                    | N                         
           | N                                    | Y      | N                  
                  | N                                    | N                    
                |
-| Array         | N                                    | Y                     
               | N                                    | N                       
             | N                                    | N                         
           | N                                    | N      | <span 
style="color:red">**Y**</span> | N                                    | N       
                             |
-| Map           | N                                    | Y                     
               | N                                    | N                       
             | N                                    | N                         
           | N                                    | N      | N                  
                  | <span style="color:red">**Y**</span> | N                    
                |
-| Struct        | N                                    | Y                     
               | N                                    | N                       
             | N                                    | N                         
           | N                                    | N      | N                  
                  | N                                    | <span 
style="color:red">**Y**</span> |
+| Source\Target | Numeric                              | String                
               | Date                                 | Time | Timestamp        
                    | Timestamp_NTZ                        | Interval           
                  | Boolean                              | Binary | Array       
                         | Map                                  | Struct        
                       |
+|---------------|--------------------------------------|--------------------------------------|--------------------------------------|------|--------------------------------------|--------------------------------------|--------------------------------------|--------------------------------------|--------|--------------------------------------|--------------------------------------|--------------------------------------|
+| Numeric       | <span style="color:red">**Y**</span> | <span 
style="color:red">**Y**</span> | N                                    | N    
|<span style="color:red">**Y**</span> | N                                    | 
<span style="color:red">**Y**</span> | Y                                    | N 
     | N                                    | N                                 
   | N                                    |
+| String        | <span style="color:red">**Y**</span> | Y                     
               | <span style="color:red">**Y**</span> | Y    |<span 
style="color:red">**Y**</span> | <span style="color:red">**Y**</span> | <span 
style="color:red">**Y**</span> | <span style="color:red">**Y**</span> | Y      
| N                                    | N                                    | 
N                                    |
+| Date          | N                                    | Y                     
               | Y                                    | N    | Y                
                   | Y                                    | N                   
                 | N                                    | N      | N            
                        | N                                    | N              
                      |
+| Time          | N                                    | Y                     
               | N                                    | Y    | N                
                   | N                                    | N                   
                 | N                                    | N      | N            
                        | N                                    | N              
                      |
+| Timestamp     | <span style="color:red">**Y**</span> | Y                     
               | Y                                    | N    | Y                
                   | Y                                    | N                   
                 | N                                    | N      | N            
                        | N                                    | N              
                      |
+| Timestamp_NTZ | N                                    | Y                     
               | Y                                    | N    | Y                
                   | Y                                    | N                   
                 | N                                    | N      | N            
                        | N                                    | N              
                      |
+| Interval      | <span style="color:red">**Y**</span> | Y                     
               | N                                    | N    | N                
                   | N                                    | Y                   
                 | N                                    | N      | N            
                        | N                                    | N              
                      |
+| Boolean       | Y                                    | Y                     
               | N                                    | N    | N                
                   | N                                    | N                   
                 | Y                                    | N      | N            
                        | N                                    | N              
                      |
+| Binary        | N                                    | Y                     
               | N                                    | N    | N                
                   | N                                    | N                   
                 | N                                    | Y      | N            
                        | N                                    | N              
                      |
+| Array         | N                                    | Y                     
               | N                                    | N    | N                
                   | N                                    | N                   
                 | N                                    | N      | <span 
style="color:red">**Y**</span> | N                                    | N       
                             |
+| Map           | N                                    | Y                     
               | N                                    | N    | N                
                   | N                                    | N                   
                 | N                                    | N      | N            
                        | <span style="color:red">**Y**</span> | N              
                      |
+| Struct        | N                                    | Y                     
               | N                                    | N    | N                
                   | N                                    | N                   
                 | N                                    | N      | N            
                        | N                                    | <span 
style="color:red">**Y**</span> |
 
 In the table above, all the `CAST`s with new syntax are marked as red <span 
style="color:red">**Y**</span>:
 * CAST(Numeric AS Numeric): raise an overflow exception if the value is out of 
the target data type's range.
@@ -198,19 +199,20 @@ While casting of a decimal with a fraction to an interval 
type with SECOND as th
 ### Store assignment
 As mentioned at the beginning, when `spark.sql.storeAssignmentPolicy` is set 
to `ANSI`(which is the default value), Spark SQL complies with the ANSI store 
assignment rules on table insertions. The valid combinations of source and 
target data type in table insertions are given by the following table.
 
-| Source\Target | Numeric | String | Date | Timestamp | Timestamp_NTZ | 
Interval | Boolean | Binary | Array | Map | Struct |
-|:-------------:|:-------:|:------:|:----:|:---------:|---------------|:--------:|:-------:|:------:|:-----:|:---:|:------:|
-|    Numeric    |    Y    |   Y    |  N   |     N     | N             |    N   
  |    N    |   N    |   N   |  N  |   N    |
-|    String     |    N    |   Y    |  N   |     N     | N             |    N   
  |    N    |   N    |   N   |  N  |   N    |
-|     Date      |    N    |   Y    |  Y   |     Y     | Y             |    N   
  |    N    |   N    |   N   |  N  |   N    |
-|   Timestamp   |    N    |   Y    |  Y   |     Y     | Y             |    N   
  |    N    |   N    |   N   |  N  |   N    |
-| Timestamp_NTZ |    N    |   Y    |  Y   |     Y     | Y             |    N   
  |    N    |   N    |   N   |  N  |   N    |
-|   Interval    |    N    |   Y    |  N   |     N     | N             |    N*  
  |    N    |   N    |   N   |  N  |   N    |
-|    Boolean    |    N    |   Y    |  N   |     N     | N             |    N   
  |    Y    |   N    |   N   |  N  |   N    |
-|    Binary     |    N    |   Y    |  N   |     N     | N             |    N   
  |    N    |   Y    |   N   |  N  |   N    |
-|     Array     |    N    |   N    |  N   |     N     | N             |    N   
  |    N    |   N    |  Y**  |  N  |   N    |
-|      Map      |    N    |   N    |  N   |     N     | N             |    N   
  |    N    |   N    |   N   | Y** |   N    |
-|    Struct     |    N    |   N    |  N   |     N     | N             |    N   
  |    N    |   N    |   N   |  N  |  Y**   |
+| Source\Target | Numeric | String | Date | Time | Timestamp | Timestamp_NTZ | 
Interval | Boolean | Binary | Array | Map | Struct |
+|:-------------:|:-------:|:------:|:----:|:----:|:---------:|---------------|:--------:|:-------:|:------:|:-----:|:---:|:------:|
+|    Numeric    |    Y    |   Y    |  N   |  N   |     N     | N             | 
   N     |    N    |   N    |   N   |  N  |   N    |
+|    String     |    N    |   Y    |  N   |  Y   |     N     | N             | 
   N     |    N    |   N    |   N   |  N  |   N    |
+|     Date      |    N    |   Y    |  Y   |  N   |     Y     | Y             | 
   N     |    N    |   N    |   N   |  N  |   N    |
+|     Time      |    N    |   Y    |  N   |  Y   |     N     | N             | 
   N     |    N    |   N    |   N   |  N  |   N    |
+|   Timestamp   |    N    |   Y    |  Y   |  N   |     Y     | Y             | 
   N     |    N    |   N    |   N   |  N  |   N    |
+| Timestamp_NTZ |    N    |   Y    |  Y   |  N   |     Y     | Y             | 
   N     |    N    |   N    |   N   |  N  |   N    |
+|   Interval    |    N    |   Y    |  N   |  N   |     N     | N             | 
   N*    |    N    |   N    |   N   |  N  |   N    |
+|    Boolean    |    N    |   Y    |  N   |  N   |     N     | N             | 
   N     |    Y    |   N    |   N   |  N  |   N    |
+|    Binary     |    N    |   Y    |  N   |  N   |     N     | N             | 
   N     |    N    |   Y    |   N   |  N  |   N    |
+|     Array     |    N    |   N    |  N   |  N   |     N     | N             | 
   N     |    N    |   N    |  Y**  |  N  |   N    |
+|      Map      |    N    |   N    |  N   |  N   |     N     | N             | 
   N     |    N    |   N    |   N   | Y** |   N    |
+|    Struct     |    N    |   N    |  N   |  N   |     N     | N             | 
   N     |    N    |   N    |   N   |  N  |  Y**   |
 
 \* Spark doesn't support interval type table column.
 
@@ -239,6 +241,7 @@ At the heart of this conflict resolution is the Type 
Precedence List which defin
 | Float     | Float -> Double                                                  
               |
 | Double    | Double                                                           
               |
 | Date      | Date -> Timestamp_NTZ -> Timestamp                               
               |
+| Time      | Time                                                             
               |
 | Timestamp | Timestamp                                                        
               |
 | String    | String, Long -> Double, Date -> Timestamp_NTZ -> Timestamp , 
Boolean, Binary ** |
 | Binary    | Binary                                                           
               |


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org
For additional commands, e-mail: commits-h...@spark.apache.org

Reply via email to