Skip to content

PARQUET-229 Add a strict thrift projection API with backwards compat support#150

Closed
isnotinvain wants to merge 19 commits intoapache:masterfrom
isnotinvain:alexlevenson/strict-projection
Closed

PARQUET-229 Add a strict thrift projection API with backwards compat support#150
isnotinvain wants to merge 19 commits intoapache:masterfrom
isnotinvain:alexlevenson/strict-projection

Conversation

@isnotinvain
Copy link
Copy Markdown
Contributor

Currently, the thrift projection API accepts strings in a very general glob format that supports not only wildcards like * and ? and expansions ({x,y,z}) but also character classes [abc], and negation.
Because of this flexibility, it's hard to give users good error reporting, for example letting them know that when they requested columns foo.bar.{a,b,c} there is actually no such column foo.bar.c.

This PR introduces a new syntax that supports a more restrictive form of glob syntax and enforces that all expansions of a glob match a column, not just that all globs match a column. The new syntax is very simple and only has four special characters: {,},,, and *

It supports glob expansion, for example:
home.{phone,address} or org.apache{-incubator,}.foo

And the wildcard * which is treated the same way as java regex treats (.*), for example:
home.* or org.apache*.foo

In the new syntax glob paths mean "keep all the child fields of the field matched by this glob", just like variable access would work in a programming language. For example: x.y.z means keep field z and all of its children (if any). So it's not necessary to do x.y.z.*. However, x.y.z would not keep field x.y.zoo. If that was desired, then x.y.z* could be used instead.

Setting "parquet.thrift.column.filter" will result in the same behavior that it does currently in master, though a deprecation warning will be logged. The classes that implement the current behavior have been marked as deprecated, and using this will log a warning.

Setting "parquet.thrift.column.projection.globs" will instead use this new syntax, and entry points in the various Builder's in the codebase is added as well.

This PR does a little bit of cleanup as well, moving some shared methods to a Strings class and simplifying some of the class hierarchy in ThriftSchemaConverterVisitor. There are a few // TODO Why? added as well that I wanted to ask about.

@isnotinvain
Copy link
Copy Markdown
Contributor Author

cc @tsdeng @julienledem

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just wanted to call this question out

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Filters are defined in terms of the thrift schema and T has to be either a Thrift of Scrooge generated class.
Possibly this should be refactored or renamed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@isnotinvain
Copy link
Copy Markdown
Contributor Author

@isnotinvain isnotinvain changed the title Add a strict thrift projection API with backwards compat support PARQUET-229 Add a strict thrift projection API with backwards compat support Mar 25, 2015
@isnotinvain
Copy link
Copy Markdown
Contributor Author

@tsdeng
Copy link
Copy Markdown
Contributor

tsdeng commented Apr 8, 2015

could you also update this doc with the new API? https://github.com/apache/incubator-parquet-mr/blob/master/parquet_cascading.md
It could serve as a tutorial for users to use it

@tsdeng
Copy link
Copy Markdown
Contributor

tsdeng commented Apr 8, 2015

minor comment, otherwise LGTM

Conflicts:
	parquet-common/src/main/java/org/apache/parquet/hadoop/metadata/ColumnPath.java
	parquet-thrift/src/main/java/org/apache/parquet/hadoop/thrift/ThriftReadSupport.java
	parquet-thrift/src/main/java/org/apache/parquet/thrift/ThriftSchemaConvertVisitor.java
	parquet-thrift/src/main/java/org/apache/parquet/thrift/ThriftSchemaConverter.java
	parquet-thrift/src/main/java/org/apache/parquet/thrift/projection/PathGlobPattern.java
	parquet-thrift/src/main/java/parquet/thrift/projection/PathGlobPattern.java
	parquet-thrift/src/main/java/parquet/thrift/projection/deprecated/PathGlobPattern.java
	parquet-thrift/src/test/java/org/apache/parquet/thrift/TestThriftSchemaConverter.java
	parquet-thrift/src/test/java/org/apache/parquet/thrift/projection/PathGlobPatternTest.java
	parquet-thrift/src/test/java/parquet/thrift/projection/PathGlobPatternTest.java
	parquet-thrift/src/test/java/parquet/thrift/projection/deprecated/PathGlobPatternTest.java
Conflicts:
	parquet-thrift/src/main/java/org/apache/parquet/hadoop/thrift/ThriftReadSupport.java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants