You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2022/09/21 12:52:59 UTC

[GitHub] [doris] Jibing-Li opened a new pull request, #12833: Get column type from parquet schema.

Jibing-Li opened a new pull request, #12833:
URL: https://github.com/apache/doris/pull/12833

   # Proposed changes
   
   Get schema from parquet reader.
   
   ## Problem summary
   
   Describe your changes.
   
   ## Checklist(Required)
   
   1. Does it affect the original behavior: 
       - [ ] Yes
       - [ ] No
       - [ ] I don't know
   2. Has unit tests been added:
       - [ ] Yes
       - [ ] No
       - [ ] No Need
   3. Has document been added or modified:
       - [ ] Yes
       - [ ] No
       - [ ] No Need
   4. Does it need to update dependencies:
       - [ ] Yes
       - [ ] No
   5. Are there any changes that cannot be rolled back:
       - [ ] Yes (If Yes, please explain WHY)
       - [ ] No
   
   ## Further comments
   
   If this is a relatively large or complex change, kick off the discussion at [dev@doris.apache.org](mailto:dev@doris.apache.org) by explaining why you chose the solution you did and what alternatives you considered, etc...
   
   


-- 
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: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] github-actions[bot] commented on pull request #12833: Get column type from parquet schema.

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #12833:
URL: https://github.com/apache/doris/pull/12833#issuecomment-1254379560

   PR approved by anyone and no changes requested.


-- 
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: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] AshinGau commented on a diff in pull request #12833: Get column type from parquet schema.

Posted by GitBox <gi...@apache.org>.
AshinGau commented on code in PR #12833:
URL: https://github.com/apache/doris/pull/12833#discussion_r976572752


##########
be/src/vec/exec/format/parquet/schema_desc.cpp:
##########
@@ -150,6 +152,70 @@ void FieldDescriptor::parse_physical_field(const tparquet::SchemaElement& physic
     physical_field->physical_type = physical_schema.type;
     _physical_fields.push_back(physical_field);
     physical_field->physical_column_index = _physical_fields.size() - 1;
+    if (physical_schema.__isset.logicalType) {
+        physical_field->type = convert_to_doris_type(physical_schema.logicalType);
+    } else if (physical_schema.__isset.converted_type) {
+        physical_field->type = convert_to_doris_type(physical_schema.converted_type);
+    }
+}
+
+TypeDescriptor FieldDescriptor::convert_to_doris_type(tparquet::LogicalType logicalType) {
+    TypeDescriptor type;
+    if (logicalType.__isset.STRING) {
+        // TODO: len?
+        type.type = TYPE_STRING;
+    } else if (logicalType.__isset.DECIMAL) {
+        type.type = TYPE_DECIMALV2;
+        type.precision = logicalType.DECIMAL.precision;
+        type.scale = logicalType.DECIMAL.scale;
+    } else if (logicalType.__isset.DATE) {
+        type.type = TYPE_DATE;
+    } else if (logicalType.__isset.INTEGER) {
+        type.type = TYPE_INT;

Review Comment:
   parquet `IntType` has `bitWidth` and `isSigned`



-- 
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: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] morningman commented on a diff in pull request #12833: Get column type from parquet schema.

Posted by GitBox <gi...@apache.org>.
morningman commented on code in PR #12833:
URL: https://github.com/apache/doris/pull/12833#discussion_r977092251


##########
be/src/vec/exec/format/parquet/schema_desc.cpp:
##########
@@ -150,6 +152,84 @@ void FieldDescriptor::parse_physical_field(const tparquet::SchemaElement& physic
     physical_field->physical_type = physical_schema.type;
     _physical_fields.push_back(physical_field);
     physical_field->physical_column_index = _physical_fields.size() - 1;
+    if (physical_schema.__isset.logicalType) {
+        physical_field->type = convert_to_doris_type(physical_schema.logicalType);
+    } else if (physical_schema.__isset.converted_type) {
+        physical_field->type = convert_to_doris_type(physical_schema.converted_type);
+    }
+}
+
+TypeDescriptor FieldDescriptor::convert_to_doris_type(tparquet::LogicalType logicalType) {
+    TypeDescriptor type;
+    if (logicalType.__isset.STRING) {
+        type.type = TYPE_STRING;
+    } else if (logicalType.__isset.DECIMAL) {
+        type.type = TYPE_DECIMALV2;
+        type.precision = 27;
+        type.scale = 9;
+    } else if (logicalType.__isset.DATE) {
+        type.type = TYPE_DATEV2;
+    } else if (logicalType.__isset.INTEGER) {
+        if (logicalType.INTEGER.isSigned) {
+            if (logicalType.INTEGER.bitWidth <= 32) {
+                type.type = TYPE_INT;
+            } else {
+                type.type = TYPE_BIGINT;
+            }
+        } else {
+            if (logicalType.INTEGER.bitWidth <= 16) {
+                type.type = TYPE_INT;
+            } else {
+                type.type = TYPE_BIGINT;
+            }
+        }
+    } else if (logicalType.__isset.TIME) {
+        type.type = TYPE_TIMEV2;
+    } else if (logicalType.__isset.TIMESTAMP) {
+        type.type = TYPE_DATETIMEV2;
+    } else {
+        LOG(WARNING) << "Not supported parquet LogicalType";

Review Comment:
   print `logicalType` in log



-- 
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: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] morningman merged pull request #12833: [feature](file scanner)Get column type from parquet schema.

Posted by GitBox <gi...@apache.org>.
morningman merged PR #12833:
URL: https://github.com/apache/doris/pull/12833


-- 
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: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] Jibing-Li commented on a diff in pull request #12833: Get column type from parquet schema.

Posted by GitBox <gi...@apache.org>.
Jibing-Li commented on code in PR #12833:
URL: https://github.com/apache/doris/pull/12833#discussion_r976674691


##########
be/src/vec/exec/format/parquet/schema_desc.cpp:
##########
@@ -150,6 +152,70 @@ void FieldDescriptor::parse_physical_field(const tparquet::SchemaElement& physic
     physical_field->physical_type = physical_schema.type;
     _physical_fields.push_back(physical_field);
     physical_field->physical_column_index = _physical_fields.size() - 1;
+    if (physical_schema.__isset.logicalType) {
+        physical_field->type = convert_to_doris_type(physical_schema.logicalType);
+    } else if (physical_schema.__isset.converted_type) {
+        physical_field->type = convert_to_doris_type(physical_schema.converted_type);
+    }
+}
+
+TypeDescriptor FieldDescriptor::convert_to_doris_type(tparquet::LogicalType logicalType) {
+    TypeDescriptor type;
+    if (logicalType.__isset.STRING) {
+        // TODO: len?
+        type.type = TYPE_STRING;
+    } else if (logicalType.__isset.DECIMAL) {
+        type.type = TYPE_DECIMALV2;
+        type.precision = logicalType.DECIMAL.precision;
+        type.scale = logicalType.DECIMAL.scale;
+    } else if (logicalType.__isset.DATE) {
+        type.type = TYPE_DATE;
+    } else if (logicalType.__isset.INTEGER) {
+        type.type = TYPE_INT;
+    } else if (logicalType.__isset.TIME) {
+        type.type = TYPE_TIMEV2;
+    } else if (logicalType.__isset.TIMESTAMP) {
+        type.type = TYPE_DATETIMEV2;
+    } else {
+        LOG(WARNING) << "Not supported parquet LogicalType";
+    }
+    return type;
+}
+
+TypeDescriptor FieldDescriptor::convert_to_doris_type(tparquet::ConvertedType::type convertedType) {
+    TypeDescriptor type;
+    switch (convertedType) {
+    case tparquet::ConvertedType::type::DECIMAL:
+        // TODO: precision and scale?

Review Comment:
   I suppose here should use fixed precision and scale as well? 27, 9



-- 
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: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] github-actions[bot] commented on pull request #12833: Get column type from parquet schema.

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #12833:
URL: https://github.com/apache/doris/pull/12833#issuecomment-1254379529

   PR approved by at least one committer and no changes requested.


-- 
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: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] github-actions[bot] commented on pull request #12833: Get column type from parquet schema.

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #12833:
URL: https://github.com/apache/doris/pull/12833#issuecomment-1254379561

   PR approved by anyone and no changes requested.


-- 
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: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] github-actions[bot] commented on pull request #12833: Get column type from parquet schema.

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #12833:
URL: https://github.com/apache/doris/pull/12833#issuecomment-1254379531

   PR approved by at least one committer and no changes requested.


-- 
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: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] AshinGau commented on a diff in pull request #12833: Get column type from parquet schema.

Posted by GitBox <gi...@apache.org>.
AshinGau commented on code in PR #12833:
URL: https://github.com/apache/doris/pull/12833#discussion_r976552276


##########
be/src/vec/exec/format/parquet/schema_desc.cpp:
##########
@@ -150,6 +152,70 @@ void FieldDescriptor::parse_physical_field(const tparquet::SchemaElement& physic
     physical_field->physical_type = physical_schema.type;
     _physical_fields.push_back(physical_field);
     physical_field->physical_column_index = _physical_fields.size() - 1;
+    if (physical_schema.__isset.logicalType) {
+        physical_field->type = convert_to_doris_type(physical_schema.logicalType);
+    } else if (physical_schema.__isset.converted_type) {
+        physical_field->type = convert_to_doris_type(physical_schema.converted_type);
+    }
+}
+
+TypeDescriptor FieldDescriptor::convert_to_doris_type(tparquet::LogicalType logicalType) {
+    TypeDescriptor type;
+    if (logicalType.__isset.STRING) {
+        // TODO: len?
+        type.type = TYPE_STRING;
+    } else if (logicalType.__isset.DECIMAL) {
+        type.type = TYPE_DECIMALV2;
+        type.precision = logicalType.DECIMAL.precision;
+        type.scale = logicalType.DECIMAL.scale;
+    } else if (logicalType.__isset.DATE) {
+        type.type = TYPE_DATE;
+    } else if (logicalType.__isset.INTEGER) {
+        type.type = TYPE_INT;
+    } else if (logicalType.__isset.TIME) {
+        type.type = TYPE_TIMEV2;
+    } else if (logicalType.__isset.TIMESTAMP) {
+        type.type = TYPE_DATETIMEV2;
+    } else {
+        LOG(WARNING) << "Not supported parquet LogicalType";
+    }
+    return type;
+}
+
+TypeDescriptor FieldDescriptor::convert_to_doris_type(tparquet::ConvertedType::type convertedType) {
+    TypeDescriptor type;
+    switch (convertedType) {
+    case tparquet::ConvertedType::type::DECIMAL:
+        // TODO: precision and scale?

Review Comment:
   `FieldSchema.parquet_schema` has precision and scale.



##########
be/src/vec/exec/format/parquet/schema_desc.cpp:
##########
@@ -150,6 +152,70 @@ void FieldDescriptor::parse_physical_field(const tparquet::SchemaElement& physic
     physical_field->physical_type = physical_schema.type;
     _physical_fields.push_back(physical_field);
     physical_field->physical_column_index = _physical_fields.size() - 1;
+    if (physical_schema.__isset.logicalType) {
+        physical_field->type = convert_to_doris_type(physical_schema.logicalType);
+    } else if (physical_schema.__isset.converted_type) {
+        physical_field->type = convert_to_doris_type(physical_schema.converted_type);
+    }
+}
+
+TypeDescriptor FieldDescriptor::convert_to_doris_type(tparquet::LogicalType logicalType) {
+    TypeDescriptor type;
+    if (logicalType.__isset.STRING) {
+        // TODO: len?
+        type.type = TYPE_STRING;
+    } else if (logicalType.__isset.DECIMAL) {
+        type.type = TYPE_DECIMALV2;

Review Comment:
   `TYPE_DECIMALV2` has fixed precision and scale



-- 
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: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org