rdblue commented on a change in pull request #4301:
URL: https://github.com/apache/iceberg/pull/4301#discussion_r840012797



##########
File path: format/spec.md
##########
@@ -965,10 +976,31 @@ Types are serialized according to this table:
 |**`fixed(L)`**|`JSON string: "fixed[<L>]"`|`"fixed[16]"`|
 |**`binary`**|`JSON string: "binary"`|`"binary"`|
 |**`decimal(P, S)`**|`JSON string: "decimal(<P>,<S>)"`|`"decimal(9,2)"`,<br 
/>`"decimal(9, 2)"`|
-|**`struct`**|`JSON object: {`<br />&nbsp;&nbsp;`"type": "struct",`<br 
/>&nbsp;&nbsp;`"fields": [ {`<br />&nbsp;&nbsp;&nbsp;&nbsp;`"id": <field id 
int>,`<br />&nbsp;&nbsp;&nbsp;&nbsp;`"name": <name string>,`<br 
/>&nbsp;&nbsp;&nbsp;&nbsp;`"required": <boolean>,`<br 
/>&nbsp;&nbsp;&nbsp;&nbsp;`"type": <type JSON>,`<br 
/>&nbsp;&nbsp;&nbsp;&nbsp;`"doc": <comment string>`<br 
/>&nbsp;&nbsp;&nbsp;&nbsp;`}, ...`<br />&nbsp;&nbsp;`] }`|`{`<br 
/>&nbsp;&nbsp;`"type": "struct",`<br />&nbsp;&nbsp;`"fields": [ {`<br 
/>&nbsp;&nbsp;&nbsp;&nbsp;`"id": 1,`<br />&nbsp;&nbsp;&nbsp;&nbsp;`"name": 
"id",`<br />&nbsp;&nbsp;&nbsp;&nbsp;`"required": true,`<br 
/>&nbsp;&nbsp;&nbsp;&nbsp;`"type": "uuid"`<br />&nbsp;&nbsp;`}, {`<br 
/>&nbsp;&nbsp;&nbsp;&nbsp;`"id": 2,`<br />&nbsp;&nbsp;&nbsp;&nbsp;`"name": 
"data",`<br />&nbsp;&nbsp;&nbsp;&nbsp;`"required": false,`<br 
/>&nbsp;&nbsp;&nbsp;&nbsp;`"type": {`<br 
/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`"type": "list",`<br 
/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`...`<br />
 &nbsp;&nbsp;&nbsp;&nbsp;`}`<br />&nbsp;&nbsp;`} ]`<br />`}`|
+|**`struct`**|`JSON object: {`<br />&nbsp;&nbsp;`"type": "struct",`<br 
/>&nbsp;&nbsp;`"fields": [ {`<br />&nbsp;&nbsp;&nbsp;&nbsp;`"id": <field id 
int>,`<br />&nbsp;&nbsp;&nbsp;&nbsp;`"name": <name string>,`<br 
/>&nbsp;&nbsp;&nbsp;&nbsp;`"required": <boolean>,`<br 
/>&nbsp;&nbsp;&nbsp;&nbsp;`"type": <type JSON>,`<br 
/>&nbsp;&nbsp;&nbsp;&nbsp;`"doc": <comment string>,`<br 
/>&nbsp;&nbsp;&nbsp;&nbsp;`"initial-default": <JSON encoding of default 
value>,`<br />&nbsp;&nbsp;&nbsp;&nbsp;`"write-default": <JSON encoding of 
default value>`<br />&nbsp;&nbsp;&nbsp;&nbsp;`}, ...`<br />&nbsp;&nbsp;`] 
}`|`{`<br />&nbsp;&nbsp;`"type": "struct",`<br />&nbsp;&nbsp;`"fields": [ {`<br 
/>&nbsp;&nbsp;&nbsp;&nbsp;`"id": 1,`<br />&nbsp;&nbsp;&nbsp;&nbsp;`"name": 
"id",`<br />&nbsp;&nbsp;&nbsp;&nbsp;`"required": true,`<br 
/>&nbsp;&nbsp;&nbsp;&nbsp;`"type": "uuid",`<br 
/>&nbsp;&nbsp;&nbsp;&nbsp;`"initial-default": 
"0db3e2a8-9d1d-42b9-aa7b-74ebe558dceb",`<br 
/>&nbsp;&nbsp;&nbsp;&nbsp;`"write-default": "ec5911be
 -b0a7-458c-8438-c9a3e53cffae"`<br />&nbsp;&nbsp;`}, {`<br 
/>&nbsp;&nbsp;&nbsp;&nbsp;`"id": 2,`<br />&nbsp;&nbsp;&nbsp;&nbsp;`"name": 
"data",`<br />&nbsp;&nbsp;&nbsp;&nbsp;`"required": false,`<br 
/>&nbsp;&nbsp;&nbsp;&nbsp;`"type": {`<br 
/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`"type": "list",`<br 
/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`...`<br />&nbsp;&nbsp;&nbsp;&nbsp;`}`<br 
/>&nbsp;&nbsp;`} ]`<br />`}`|
 |**`list`**|`JSON object: {`<br />&nbsp;&nbsp;`"type": "list",`<br 
/>&nbsp;&nbsp;`"element-id": <id int>,`<br />&nbsp;&nbsp;`"element-required": 
<bool>`<br />&nbsp;&nbsp;`"element": <type JSON>`<br />`}`|`{`<br 
/>&nbsp;&nbsp;`"type": "list",`<br />&nbsp;&nbsp;`"element-id": 3,`<br 
/>&nbsp;&nbsp;`"element-required": true,`<br />&nbsp;&nbsp;`"element": 
"string"`<br />`}`|
 |**`map`**|`JSON object: {`<br />&nbsp;&nbsp;`"type": "map",`<br 
/>&nbsp;&nbsp;`"key-id": <key id int>,`<br />&nbsp;&nbsp;`"key": <type 
JSON>,`<br />&nbsp;&nbsp;`"value-id": <val id int>,`<br 
/>&nbsp;&nbsp;`"value-required": <bool>`<br />&nbsp;&nbsp;`"value": <type 
JSON>`<br />`}`|`{`<br />&nbsp;&nbsp;`"type": "map",`<br 
/>&nbsp;&nbsp;`"key-id": 4,`<br />&nbsp;&nbsp;`"key": "string",`<br 
/>&nbsp;&nbsp;`"value-id": 5,`<br />&nbsp;&nbsp;`"value-required": false,`<br 
/>&nbsp;&nbsp;`"value": "double"`<br />`}`|
 
+For default values, the serialization depends on the type of the corresponding 
column or nested field. The mapping of types and their corresponding default 
value JSON serialization is described in the following table:
+
+| Type               | Json type          | Example                            
      | Note                                                                    
                                                                                
                                                                                
                                                                                
  |
+|--------------------|--------------------|------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
+| **`boolean`**      | **`json boolean`** | `true`                             
      |                                                                         
                                                                                
                                                                                
                                                                                
  |
+| **`int`**          | **`json int`**     | `1`                                
      |                                                                         
                                                                                
                                                                                
                                                                                
  |
+| **`long`**         | **`json long`**    | `1`                                
      |                                                                         
                                                                                
                                                                                
                                                                                
  |
+| **`float`**        | **`json float`**   | `1.1`                              
      |                                                                         
                                                                                
                                                                                
                                                                                
  |
+| **`double`**       | **`json double`**  | `1.1`                              
      |                                                                         
                                                                                
                                                                                
                                                                                
  |
+| **`decimal(P,S)`** | **`string`**       | `"0x3162"`                         
      | Stores the unscaled value, as the two's-complement big-endian binary 
using the minimum number of bytes, converted to a hexadecimal string prefixed 
by `0x`                                                                         
                                                                                
       |

Review comment:
       I think @RussellSpitzer suggested that we store these values as natural 
strings and I agree. This should be `"123.45"` rather than the unscaled value.

##########
File path: format/spec.md
##########
@@ -965,10 +976,31 @@ Types are serialized according to this table:
 |**`fixed(L)`**|`JSON string: "fixed[<L>]"`|`"fixed[16]"`|
 |**`binary`**|`JSON string: "binary"`|`"binary"`|
 |**`decimal(P, S)`**|`JSON string: "decimal(<P>,<S>)"`|`"decimal(9,2)"`,<br 
/>`"decimal(9, 2)"`|
-|**`struct`**|`JSON object: {`<br />&nbsp;&nbsp;`"type": "struct",`<br 
/>&nbsp;&nbsp;`"fields": [ {`<br />&nbsp;&nbsp;&nbsp;&nbsp;`"id": <field id 
int>,`<br />&nbsp;&nbsp;&nbsp;&nbsp;`"name": <name string>,`<br 
/>&nbsp;&nbsp;&nbsp;&nbsp;`"required": <boolean>,`<br 
/>&nbsp;&nbsp;&nbsp;&nbsp;`"type": <type JSON>,`<br 
/>&nbsp;&nbsp;&nbsp;&nbsp;`"doc": <comment string>`<br 
/>&nbsp;&nbsp;&nbsp;&nbsp;`}, ...`<br />&nbsp;&nbsp;`] }`|`{`<br 
/>&nbsp;&nbsp;`"type": "struct",`<br />&nbsp;&nbsp;`"fields": [ {`<br 
/>&nbsp;&nbsp;&nbsp;&nbsp;`"id": 1,`<br />&nbsp;&nbsp;&nbsp;&nbsp;`"name": 
"id",`<br />&nbsp;&nbsp;&nbsp;&nbsp;`"required": true,`<br 
/>&nbsp;&nbsp;&nbsp;&nbsp;`"type": "uuid"`<br />&nbsp;&nbsp;`}, {`<br 
/>&nbsp;&nbsp;&nbsp;&nbsp;`"id": 2,`<br />&nbsp;&nbsp;&nbsp;&nbsp;`"name": 
"data",`<br />&nbsp;&nbsp;&nbsp;&nbsp;`"required": false,`<br 
/>&nbsp;&nbsp;&nbsp;&nbsp;`"type": {`<br 
/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`"type": "list",`<br 
/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`...`<br />
 &nbsp;&nbsp;&nbsp;&nbsp;`}`<br />&nbsp;&nbsp;`} ]`<br />`}`|
+|**`struct`**|`JSON object: {`<br />&nbsp;&nbsp;`"type": "struct",`<br 
/>&nbsp;&nbsp;`"fields": [ {`<br />&nbsp;&nbsp;&nbsp;&nbsp;`"id": <field id 
int>,`<br />&nbsp;&nbsp;&nbsp;&nbsp;`"name": <name string>,`<br 
/>&nbsp;&nbsp;&nbsp;&nbsp;`"required": <boolean>,`<br 
/>&nbsp;&nbsp;&nbsp;&nbsp;`"type": <type JSON>,`<br 
/>&nbsp;&nbsp;&nbsp;&nbsp;`"doc": <comment string>,`<br 
/>&nbsp;&nbsp;&nbsp;&nbsp;`"initial-default": <JSON encoding of default 
value>,`<br />&nbsp;&nbsp;&nbsp;&nbsp;`"write-default": <JSON encoding of 
default value>`<br />&nbsp;&nbsp;&nbsp;&nbsp;`}, ...`<br />&nbsp;&nbsp;`] 
}`|`{`<br />&nbsp;&nbsp;`"type": "struct",`<br />&nbsp;&nbsp;`"fields": [ {`<br 
/>&nbsp;&nbsp;&nbsp;&nbsp;`"id": 1,`<br />&nbsp;&nbsp;&nbsp;&nbsp;`"name": 
"id",`<br />&nbsp;&nbsp;&nbsp;&nbsp;`"required": true,`<br 
/>&nbsp;&nbsp;&nbsp;&nbsp;`"type": "uuid",`<br 
/>&nbsp;&nbsp;&nbsp;&nbsp;`"initial-default": 
"0db3e2a8-9d1d-42b9-aa7b-74ebe558dceb",`<br 
/>&nbsp;&nbsp;&nbsp;&nbsp;`"write-default": "ec5911be
 -b0a7-458c-8438-c9a3e53cffae"`<br />&nbsp;&nbsp;`}, {`<br 
/>&nbsp;&nbsp;&nbsp;&nbsp;`"id": 2,`<br />&nbsp;&nbsp;&nbsp;&nbsp;`"name": 
"data",`<br />&nbsp;&nbsp;&nbsp;&nbsp;`"required": false,`<br 
/>&nbsp;&nbsp;&nbsp;&nbsp;`"type": {`<br 
/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`"type": "list",`<br 
/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`...`<br />&nbsp;&nbsp;&nbsp;&nbsp;`}`<br 
/>&nbsp;&nbsp;`} ]`<br />`}`|
 |**`list`**|`JSON object: {`<br />&nbsp;&nbsp;`"type": "list",`<br 
/>&nbsp;&nbsp;`"element-id": <id int>,`<br />&nbsp;&nbsp;`"element-required": 
<bool>`<br />&nbsp;&nbsp;`"element": <type JSON>`<br />`}`|`{`<br 
/>&nbsp;&nbsp;`"type": "list",`<br />&nbsp;&nbsp;`"element-id": 3,`<br 
/>&nbsp;&nbsp;`"element-required": true,`<br />&nbsp;&nbsp;`"element": 
"string"`<br />`}`|
 |**`map`**|`JSON object: {`<br />&nbsp;&nbsp;`"type": "map",`<br 
/>&nbsp;&nbsp;`"key-id": <key id int>,`<br />&nbsp;&nbsp;`"key": <type 
JSON>,`<br />&nbsp;&nbsp;`"value-id": <val id int>,`<br 
/>&nbsp;&nbsp;`"value-required": <bool>`<br />&nbsp;&nbsp;`"value": <type 
JSON>`<br />`}`|`{`<br />&nbsp;&nbsp;`"type": "map",`<br 
/>&nbsp;&nbsp;`"key-id": 4,`<br />&nbsp;&nbsp;`"key": "string",`<br 
/>&nbsp;&nbsp;`"value-id": 5,`<br />&nbsp;&nbsp;`"value-required": false,`<br 
/>&nbsp;&nbsp;`"value": "double"`<br />`}`|
 
+For default values, the serialization depends on the type of the corresponding 
column or nested field. The mapping of types and their corresponding default 
value JSON serialization is described in the following table:
+
+| Type               | Json type          | Example                            
      | Note                                                                    
                                                                                
                                                                                
                                                                                
  |
+|--------------------|--------------------|------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
+| **`boolean`**      | **`json boolean`** | `true`                             
      |                                                                         
                                                                                
                                                                                
                                                                                
  |
+| **`int`**          | **`json int`**     | `1`                                
      |                                                                         
                                                                                
                                                                                
                                                                                
  |
+| **`long`**         | **`json long`**    | `1`                                
      |                                                                         
                                                                                
                                                                                
                                                                                
  |
+| **`float`**        | **`json float`**   | `1.1`                              
      |                                                                         
                                                                                
                                                                                
                                                                                
  |
+| **`double`**       | **`json double`**  | `1.1`                              
      |                                                                         
                                                                                
                                                                                
                                                                                
  |
+| **`decimal(P,S)`** | **`string`**       | `"0x3162"`                         
      | Stores the unscaled value, as the two's-complement big-endian binary 
using the minimum number of bytes, converted to a hexadecimal string prefixed 
by `0x`                                                                         
                                                                                
       |

Review comment:
       I think @RussellSpitzer suggested that we store these values as natural 
strings and I agree. This should be `"123.45"` rather than the unscaled value 
as binary.




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