You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@drill.apache.org by abhipol <gi...@git.apache.org> on 2015/11/03 04:17:59 UTC
[GitHub] drill pull request: DRILL-951:CSV header row should be parsed
GitHub user abhipol opened a pull request:
https://github.com/apache/drill/pull/232
DRILL-951:CSV header row should be parsed
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/abhipol/drill issues/DRILL-951
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/drill/pull/232.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #232
----
commit c744888ccb700ee1a8bd0d80920ea0d2e68e2ff4
Author: Abhi P <ab...@dremio.com>
Date: 2015-11-03T03:03:04Z
DRILL-951 supporting csv header row parsing
commit cc1e0a9c2cd95c4b9982d88578ed7d014e3de12b
Author: Abhi P <ab...@dremio.com>
Date: 2015-11-03T03:03:04Z
DRILL-951 supporting csv header row parsing
commit b75db629a2f2796005bd44c7b90e78dc11405e02
Author: Abhi P <ab...@dremio.com>
Date: 2015-11-03T03:06:29Z
Merge branch 'issues/DRILL-951' of https://github.com/abhipol/drill into issues/DRILL-951
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill pull request: DRILL-951:CSV header row should be parsed
Posted by abhipol <gi...@git.apache.org>.
Github user abhipol commented on a diff in the pull request:
https://github.com/apache/drill/pull/232#discussion_r43721299
--- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/store/easy/text/compliant/CompliantTextRecordReader.java ---
@@ -71,15 +79,14 @@ public CompliantTextRecordReader(FileSplit split, DrillFileSystem dfs, FragmentC
// checks to see if we are querying all columns(star) or individual columns
@Override
public boolean isStarQuery() {
- if(settings.isUseRepeatedVarChar()) {
- return super.isStarQuery() || Iterables.tryFind(getColumns(), new Predicate<SchemaPath>() {
- @Override
- public boolean apply(@Nullable SchemaPath path) {
- return path.equals(RepeatedVarCharOutput.COLUMNS);
- }
- }).isPresent();
- }
- return super.isStarQuery();
+ if (super.isStarQuery()) { return true; }
--- End diff --
not sure if I understood your suggestion. it does work with columns[] (ext csv) and named field cases (ext csvh), star and non star queries.
Since it was not function of UseRepeatedVarChar I simplified the code
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill pull request: DRILL-951:CSV header row should be parsed
Posted by jacques-n <gi...@git.apache.org>.
Github user jacques-n commented on a diff in the pull request:
https://github.com/apache/drill/pull/232#discussion_r43765441
--- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/store/easy/text/compliant/CompliantTextRecordReader.java ---
@@ -71,15 +79,14 @@ public CompliantTextRecordReader(FileSplit split, DrillFileSystem dfs, FragmentC
// checks to see if we are querying all columns(star) or individual columns
@Override
public boolean isStarQuery() {
- if(settings.isUseRepeatedVarChar()) {
- return super.isStarQuery() || Iterables.tryFind(getColumns(), new Predicate<SchemaPath>() {
- @Override
- public boolean apply(@Nullable SchemaPath path) {
- return path.equals(RepeatedVarCharOutput.COLUMNS);
- }
- }).isPresent();
- }
- return super.isStarQuery();
+ if (super.isStarQuery()) { return true; }
--- End diff --
If we're in header extraction mode, requesting the columns column shouldn't mean a request for star query. Only a * should.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill pull request: DRILL-951:CSV header row should be parsed
Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:
https://github.com/apache/drill/pull/232
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill pull request: DRILL-951:CSV header row should be parsed
Posted by jacques-n <gi...@git.apache.org>.
Github user jacques-n commented on a diff in the pull request:
https://github.com/apache/drill/pull/232#discussion_r43716276
--- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/store/easy/text/compliant/CompliantTextRecordReader.java ---
@@ -101,16 +108,23 @@ public void setup(OperatorContext context, OutputMutator outputMutator) throws E
InputStream stream = dfs.openPossiblyCompressedStream(split.getPath());
TextInput input = new TextInput(settings, stream, readBuffer, split.getStart(), split.getStart() + split.getLength());
- TextOutput output = null;
if(settings.isUseRepeatedVarChar()){
- output = new RepeatedVarCharOutput(outputMutator, getColumns(), isStarQuery());
- }else{
- //TODO: Add field output.
- throw new UnsupportedOperationException();
+ TextOutput output = new RepeatedVarCharOutput(outputMutator, getColumns(), isStarQuery());
+ this.reader = new TextReader(settings, input, output, whitespaceBuffer);
+ reader.start();
+ } else {
+ // two-phase read approach.
+ // phase-1: read the header from the file
+ String [] fieldNames = extractHeader(input);
+
+ // phase-2: now read the data
+ stream = dfs.openPossiblyCompressedStream(split.getPath());
+ input = new TextInput(settings, stream, readBuffer, split.getStart(), split.getStart() + split.getLength());
+ TextOutput output = new FieldVarCharOutput(outputMutator, fieldNames, getColumns(), isStarQuery());
+ this.reader = new TextReader(settings, input, output, whitespaceBuffer);
--- End diff --
These last two lines can probably be pulled out of the if/else
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill pull request: DRILL-951:CSV header row should be parsed
Posted by abhipol <gi...@git.apache.org>.
Github user abhipol commented on a diff in the pull request:
https://github.com/apache/drill/pull/232#discussion_r43721290
--- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/store/easy/text/compliant/TextParsingSettings.java ---
@@ -57,6 +56,14 @@ public void set(TextFormatConfig config){
this.delimiter = bSafe(config.getFieldDelimiter(), "fieldDelimiter");
this.comment = bSafe(config.getComment(), "comment");
this.skipFirstLine = config.isSkipFirstLine();
+ //TODO: avoid specific extension based check
--- End diff --
csvh is part of the format plugin config
added extractHeader property and cleared the TextParsingSettings code. will upload with other changes.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill pull request: DRILL-951:CSV header row should be parsed
Posted by jacques-n <gi...@git.apache.org>.
Github user jacques-n commented on a diff in the pull request:
https://github.com/apache/drill/pull/232#discussion_r43716151
--- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/store/easy/text/compliant/CompliantTextRecordReader.java ---
@@ -71,15 +79,14 @@ public CompliantTextRecordReader(FileSplit split, DrillFileSystem dfs, FragmentC
// checks to see if we are querying all columns(star) or individual columns
@Override
public boolean isStarQuery() {
- if(settings.isUseRepeatedVarChar()) {
- return super.isStarQuery() || Iterables.tryFind(getColumns(), new Predicate<SchemaPath>() {
- @Override
- public boolean apply(@Nullable SchemaPath path) {
- return path.equals(RepeatedVarCharOutput.COLUMNS);
- }
- }).isPresent();
- }
- return super.isStarQuery();
+ if (super.isStarQuery()) { return true; }
--- End diff --
Can you work with @StevenMPhillips on how to resolve this so that it works in both the columns[] and named field cases.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill pull request: DRILL-951:CSV header row should be parsed
Posted by jacques-n <gi...@git.apache.org>.
Github user jacques-n commented on a diff in the pull request:
https://github.com/apache/drill/pull/232#discussion_r43716119
--- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/store/easy/text/compliant/TextParsingSettings.java ---
@@ -57,6 +56,14 @@ public void set(TextFormatConfig config){
this.delimiter = bSafe(config.getFieldDelimiter(), "fieldDelimiter");
this.comment = bSafe(config.getComment(), "comment");
this.skipFirstLine = config.isSkipFirstLine();
+ //TODO: avoid specific extension based check
--- End diff --
You can make this work correctly by using a format plugin config. You can add csvh here:
https://github.com/apache/drill/blob/master/exec/java-exec/src/main/resources/bootstrap-storage-plugins.json
Basically, create a new item in the map. Note how the text formats are a subset of the TextFormatConfig class. You can add a new property that tells you to perform header extraction. See the properties here [1] that correspond to the format properties: [1] https://github.com/apache/drill/blob/master/exec/java-exec/src/main/java/org/apache/drill/exec/store/easy/text/TextFormatPlugin.java#L134
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill pull request: DRILL-951:CSV header row should be parsed
Posted by abhipol <gi...@git.apache.org>.
Github user abhipol commented on a diff in the pull request:
https://github.com/apache/drill/pull/232#discussion_r43721297
--- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/store/easy/text/compliant/CompliantTextRecordReader.java ---
@@ -101,16 +108,23 @@ public void setup(OperatorContext context, OutputMutator outputMutator) throws E
InputStream stream = dfs.openPossiblyCompressedStream(split.getPath());
TextInput input = new TextInput(settings, stream, readBuffer, split.getStart(), split.getStart() + split.getLength());
- TextOutput output = null;
if(settings.isUseRepeatedVarChar()){
- output = new RepeatedVarCharOutput(outputMutator, getColumns(), isStarQuery());
- }else{
- //TODO: Add field output.
- throw new UnsupportedOperationException();
+ TextOutput output = new RepeatedVarCharOutput(outputMutator, getColumns(), isStarQuery());
+ this.reader = new TextReader(settings, input, output, whitespaceBuffer);
+ reader.start();
+ } else {
+ // two-phase read approach.
+ // phase-1: read the header from the file
+ String [] fieldNames = extractHeader(input);
+
+ // phase-2: now read the data
+ stream = dfs.openPossiblyCompressedStream(split.getPath());
+ input = new TextInput(settings, stream, readBuffer, split.getStart(), split.getStart() + split.getLength());
+ TextOutput output = new FieldVarCharOutput(outputMutator, fieldNames, getColumns(), isStarQuery());
+ this.reader = new TextReader(settings, input, output, whitespaceBuffer);
--- End diff --
the second output is using FieldVarCharOutput
I made few cosmetic changes for better flow. will upload with other changes.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---