You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by GitBox <gi...@apache.org> on 2020/05/29 14:41:20 UTC
[GitHub] [iceberg] waterlx opened a new pull request #1077: Fix NPE when counting entries
waterlx opened a new pull request #1077:
URL: https://github.com/apache/iceberg/pull/1077
This PR is to address a NPE when counting on table's entries (found by @jerryshao), which could be triggered by
```
spark.read.format("iceberg").load("db.table.entries").count()
```
The following stacktrace is as follow:
```
```
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] waterlx commented on pull request #1077: Fix NPE when counting entries
Posted by GitBox <gi...@apache.org>.
waterlx commented on pull request #1077:
URL: https://github.com/apache/iceberg/pull/1077#issuecomment-636017299
When calling `count()` on entries, Spark passes newRequestedSchema (with size = 0) to Reader#pruneColumns(). As a result, a wrong schema (empty) is generated by Reader#lazySchema(). Those eventually trigger the NPE when calling get() against an empty BiMap returned by Schema#lazyNameToId().
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] waterlx commented on pull request #1077: Fix NPE when counting entries
Posted by GitBox <gi...@apache.org>.
waterlx commented on pull request #1077:
URL: https://github.com/apache/iceberg/pull/1077#issuecomment-636366663
@rdblue thanks for reviewing and sharing your idea!
The UT get passed with your fix but I met the following exception when testing your fix on my laptop (master = local[*]) and I am trying to figure out why (data_file is missing after projection)
```
java.lang.IllegalArgumentException: Missing required field: data_file
at org.apache.iceberg.relocated.com.google.common.base.Preconditions.checkArgument(Preconditions.java:217)
at org.apache.iceberg.avro.BuildAvroProjection.record(BuildAvroProjection.java:96)
at org.apache.iceberg.avro.BuildAvroProjection.record(BuildAvroProjection.java:41)
at org.apache.iceberg.avro.AvroCustomOrderSchemaVisitor.visit(AvroCustomOrderSchemaVisitor.java:51)
at org.apache.iceberg.avro.AvroSchemaUtil.buildAvroProjection(AvroSchemaUtil.java:104)
at org.apache.iceberg.avro.ProjectionDatumReader.setSchema(ProjectionDatumReader.java:60)
at org.apache.iceberg.shaded.org.apache.avro.file.DataFileStream.initialize(DataFileStream.java:132)
at org.apache.iceberg.shaded.org.apache.avro.file.DataFileReader.<init>(DataFileReader.java:106)
at org.apache.iceberg.shaded.org.apache.avro.file.DataFileReader.<init>(DataFileReader.java:98)
at org.apache.iceberg.shaded.org.apache.avro.file.DataFileReader.openReader(DataFileReader.java:66)
at org.apache.iceberg.avro.AvroIterable.newFileReader(AvroIterable.java:94)
at org.apache.iceberg.avro.AvroIterable.iterator(AvroIterable.java:77)
at org.apache.iceberg.io.CloseableIterable$3$1.<init>(CloseableIterable.java:95)
at org.apache.iceberg.io.CloseableIterable$3.iterator(CloseableIterable.java:94)
at org.apache.iceberg.io.CloseableIterable$3$1.<init>(CloseableIterable.java:95)
at org.apache.iceberg.io.CloseableIterable$3.iterator(CloseableIterable.java:94)
at org.apache.iceberg.io.CloseableIterable$3$1.<init>(CloseableIterable.java:95)
at org.apache.iceberg.io.CloseableIterable$3.iterator(CloseableIterable.java:94)
at org.apache.iceberg.io.CloseableIterable$3$1.<init>(CloseableIterable.java:95)
at org.apache.iceberg.io.CloseableIterable$3.iterator(CloseableIterable.java:94)
at org.apache.iceberg.spark.source.RowDataReader.open(RowDataReader.java:103)
at org.apache.iceberg.spark.source.BaseDataReader.next(BaseDataReader.java:75)
at org.apache.spark.sql.execution.datasources.v2.DataSourceRDD$$anon$1.hasNext(DataSourceRDD.scala:49)
at org.apache.spark.InterruptibleIterator.hasNext(InterruptibleIterator.scala:37)
at org.apache.spark.sql.catalyst.expressions.GeneratedClass$GeneratedIteratorForCodegenStage1.agg_doAggregateWithoutKey_1$(Unknown Source)
at org.apache.spark.sql.catalyst.expressions.GeneratedClass$GeneratedIteratorForCodegenStage1.agg_doAggregateWithoutKey_0$(Unknown Source)
at org.apache.spark.sql.catalyst.expressions.GeneratedClass$GeneratedIteratorForCodegenStage1.processNext(Unknown Source)
at org.apache.spark.sql.execution.BufferedRowIterator.hasNext(BufferedRowIterator.java:43)
at org.apache.spark.sql.execution.WholeStageCodegenExec$$anonfun$13$$anon$1.hasNext(WholeStageCodegenExec.scala:636)
at org.apache.spark.sql.execution.SparkPlan$$anonfun$2.apply(SparkPlan.scala:255)
at org.apache.spark.sql.execution.SparkPlan$$anonfun$2.apply(SparkPlan.scala:247)
at org.apache.spark.rdd.RDD$$anonfun$mapPartitionsInternal$1$$anonfun$apply$24.apply(RDD.scala:858)
at org.apache.spark.rdd.RDD$$anonfun$mapPartitionsInternal$1$$anonfun$apply$24.apply(RDD.scala:858)
at org.apache.spark.rdd.MapPartitionsRDD.compute(MapPartitionsRDD.scala:52)
at org.apache.spark.rdd.RDD.computeOrReadCheckpoint(RDD.scala:346)
at org.apache.spark.rdd.RDD.iterator(RDD.scala:310)
at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:90)
at org.apache.spark.scheduler.Task.run(Task.scala:123)
at org.apache.spark.executor.Executor$TaskRunner$$anonfun$10.apply(Executor.scala:408)
at org.apache.spark.util.Utils$.tryWithSafeFinally(Utils.scala:1360)
at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:414)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
```
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] waterlx edited a comment on pull request #1077: Fix NPE when counting entries
Posted by GitBox <gi...@apache.org>.
waterlx edited a comment on pull request #1077:
URL: https://github.com/apache/iceberg/pull/1077#issuecomment-636478762
@rdblue The PR is updated.
The following code you suggested
```
Schema fileSchema = fileProjection != null ? new Schema(fileProjection.asStructType().fields()) new Schema();
```
is updated as
```
Schema fileSchema = fileProjection != null ? new Schema(fileProjection.asStructType().fields()) : null;
```
When meeting the null file projection (yielded by projecting 0 columns), it returns null instead of an empty schema, to address the issue of `Missing required field: data_file` mentioned [here](https://github.com/apache/iceberg/pull/1077#issuecomment-636366663). The issue is quite weird to me as it does not break the UT while it only happends on my local test with master as local[].
Returning an empty schema seems not work as expected in [BaseManifestReader#projection()](https://github.com/apache/iceberg/blob/201f8bf0e5084daa9fcc1e8418762ecb10967036/core/src/main/java/org/apache/iceberg/BaseManifestReader.java#L237) when setting project as an empty schema.
But fixing it by returning null seems go back to the way of not supporting 0 columns.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] waterlx edited a comment on pull request #1077: Fix NPE when counting entries
Posted by GitBox <gi...@apache.org>.
waterlx edited a comment on pull request #1077:
URL: https://github.com/apache/iceberg/pull/1077#issuecomment-636366663
@rdblue thanks for reviewing and sharing your idea!
The UT get passed with your fix but I met the following exception when testing your fix on my laptop (master = local[*]) and did not find the root cause yet
```
java.lang.IllegalArgumentException: Missing required field: data_file
at org.apache.iceberg.relocated.com.google.common.base.Preconditions.checkArgument(Preconditions.java:217)
at org.apache.iceberg.avro.BuildAvroProjection.record(BuildAvroProjection.java:96)
at org.apache.iceberg.avro.BuildAvroProjection.record(BuildAvroProjection.java:41)
at org.apache.iceberg.avro.AvroCustomOrderSchemaVisitor.visit(AvroCustomOrderSchemaVisitor.java:51)
at org.apache.iceberg.avro.AvroSchemaUtil.buildAvroProjection(AvroSchemaUtil.java:104)
at org.apache.iceberg.avro.ProjectionDatumReader.setSchema(ProjectionDatumReader.java:60)
at org.apache.iceberg.shaded.org.apache.avro.file.DataFileStream.initialize(DataFileStream.java:132)
at org.apache.iceberg.shaded.org.apache.avro.file.DataFileReader.<init>(DataFileReader.java:106)
at org.apache.iceberg.shaded.org.apache.avro.file.DataFileReader.<init>(DataFileReader.java:98)
at org.apache.iceberg.shaded.org.apache.avro.file.DataFileReader.openReader(DataFileReader.java:66)
at org.apache.iceberg.avro.AvroIterable.newFileReader(AvroIterable.java:94)
at org.apache.iceberg.avro.AvroIterable.iterator(AvroIterable.java:77)
at org.apache.iceberg.io.CloseableIterable$3$1.<init>(CloseableIterable.java:95)
at org.apache.iceberg.io.CloseableIterable$3.iterator(CloseableIterable.java:94)
at org.apache.iceberg.io.CloseableIterable$3$1.<init>(CloseableIterable.java:95)
at org.apache.iceberg.io.CloseableIterable$3.iterator(CloseableIterable.java:94)
at org.apache.iceberg.io.CloseableIterable$3$1.<init>(CloseableIterable.java:95)
at org.apache.iceberg.io.CloseableIterable$3.iterator(CloseableIterable.java:94)
at org.apache.iceberg.io.CloseableIterable$3$1.<init>(CloseableIterable.java:95)
at org.apache.iceberg.io.CloseableIterable$3.iterator(CloseableIterable.java:94)
at org.apache.iceberg.spark.source.RowDataReader.open(RowDataReader.java:103)
at org.apache.iceberg.spark.source.BaseDataReader.next(BaseDataReader.java:75)
at org.apache.spark.sql.execution.datasources.v2.DataSourceRDD$$anon$1.hasNext(DataSourceRDD.scala:49)
at org.apache.spark.InterruptibleIterator.hasNext(InterruptibleIterator.scala:37)
at org.apache.spark.sql.catalyst.expressions.GeneratedClass$GeneratedIteratorForCodegenStage1.agg_doAggregateWithoutKey_1$(Unknown Source)
at org.apache.spark.sql.catalyst.expressions.GeneratedClass$GeneratedIteratorForCodegenStage1.agg_doAggregateWithoutKey_0$(Unknown Source)
at org.apache.spark.sql.catalyst.expressions.GeneratedClass$GeneratedIteratorForCodegenStage1.processNext(Unknown Source)
at org.apache.spark.sql.execution.BufferedRowIterator.hasNext(BufferedRowIterator.java:43)
at org.apache.spark.sql.execution.WholeStageCodegenExec$$anonfun$13$$anon$1.hasNext(WholeStageCodegenExec.scala:636)
at org.apache.spark.sql.execution.SparkPlan$$anonfun$2.apply(SparkPlan.scala:255)
at org.apache.spark.sql.execution.SparkPlan$$anonfun$2.apply(SparkPlan.scala:247)
at org.apache.spark.rdd.RDD$$anonfun$mapPartitionsInternal$1$$anonfun$apply$24.apply(RDD.scala:858)
at org.apache.spark.rdd.RDD$$anonfun$mapPartitionsInternal$1$$anonfun$apply$24.apply(RDD.scala:858)
at org.apache.spark.rdd.MapPartitionsRDD.compute(MapPartitionsRDD.scala:52)
at org.apache.spark.rdd.RDD.computeOrReadCheckpoint(RDD.scala:346)
at org.apache.spark.rdd.RDD.iterator(RDD.scala:310)
at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:90)
at org.apache.spark.scheduler.Task.run(Task.scala:123)
at org.apache.spark.executor.Executor$TaskRunner$$anonfun$10.apply(Executor.scala:408)
at org.apache.spark.util.Utils$.tryWithSafeFinally(Utils.scala:1360)
at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:414)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
```
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] waterlx edited a comment on pull request #1077: Fix NPE when counting entries
Posted by GitBox <gi...@apache.org>.
waterlx edited a comment on pull request #1077:
URL: https://github.com/apache/iceberg/pull/1077#issuecomment-636366663
@rdblue thanks for reviewing and sharing your idea!
The UT get passed with your fix but I met the following exception when testing your fix on my laptop (master = local[*]) and did not find the root cause yet(data_file is missing after column pruning, only status and snapshot_id are retained)
```
java.lang.IllegalArgumentException: Missing required field: data_file
at org.apache.iceberg.relocated.com.google.common.base.Preconditions.checkArgument(Preconditions.java:217)
at org.apache.iceberg.avro.BuildAvroProjection.record(BuildAvroProjection.java:96)
at org.apache.iceberg.avro.BuildAvroProjection.record(BuildAvroProjection.java:41)
at org.apache.iceberg.avro.AvroCustomOrderSchemaVisitor.visit(AvroCustomOrderSchemaVisitor.java:51)
at org.apache.iceberg.avro.AvroSchemaUtil.buildAvroProjection(AvroSchemaUtil.java:104)
at org.apache.iceberg.avro.ProjectionDatumReader.setSchema(ProjectionDatumReader.java:60)
at org.apache.iceberg.shaded.org.apache.avro.file.DataFileStream.initialize(DataFileStream.java:132)
at org.apache.iceberg.shaded.org.apache.avro.file.DataFileReader.<init>(DataFileReader.java:106)
at org.apache.iceberg.shaded.org.apache.avro.file.DataFileReader.<init>(DataFileReader.java:98)
at org.apache.iceberg.shaded.org.apache.avro.file.DataFileReader.openReader(DataFileReader.java:66)
at org.apache.iceberg.avro.AvroIterable.newFileReader(AvroIterable.java:94)
at org.apache.iceberg.avro.AvroIterable.iterator(AvroIterable.java:77)
at org.apache.iceberg.io.CloseableIterable$3$1.<init>(CloseableIterable.java:95)
at org.apache.iceberg.io.CloseableIterable$3.iterator(CloseableIterable.java:94)
at org.apache.iceberg.io.CloseableIterable$3$1.<init>(CloseableIterable.java:95)
at org.apache.iceberg.io.CloseableIterable$3.iterator(CloseableIterable.java:94)
at org.apache.iceberg.io.CloseableIterable$3$1.<init>(CloseableIterable.java:95)
at org.apache.iceberg.io.CloseableIterable$3.iterator(CloseableIterable.java:94)
at org.apache.iceberg.io.CloseableIterable$3$1.<init>(CloseableIterable.java:95)
at org.apache.iceberg.io.CloseableIterable$3.iterator(CloseableIterable.java:94)
at org.apache.iceberg.spark.source.RowDataReader.open(RowDataReader.java:103)
at org.apache.iceberg.spark.source.BaseDataReader.next(BaseDataReader.java:75)
at org.apache.spark.sql.execution.datasources.v2.DataSourceRDD$$anon$1.hasNext(DataSourceRDD.scala:49)
at org.apache.spark.InterruptibleIterator.hasNext(InterruptibleIterator.scala:37)
at org.apache.spark.sql.catalyst.expressions.GeneratedClass$GeneratedIteratorForCodegenStage1.agg_doAggregateWithoutKey_1$(Unknown Source)
at org.apache.spark.sql.catalyst.expressions.GeneratedClass$GeneratedIteratorForCodegenStage1.agg_doAggregateWithoutKey_0$(Unknown Source)
at org.apache.spark.sql.catalyst.expressions.GeneratedClass$GeneratedIteratorForCodegenStage1.processNext(Unknown Source)
at org.apache.spark.sql.execution.BufferedRowIterator.hasNext(BufferedRowIterator.java:43)
at org.apache.spark.sql.execution.WholeStageCodegenExec$$anonfun$13$$anon$1.hasNext(WholeStageCodegenExec.scala:636)
at org.apache.spark.sql.execution.SparkPlan$$anonfun$2.apply(SparkPlan.scala:255)
at org.apache.spark.sql.execution.SparkPlan$$anonfun$2.apply(SparkPlan.scala:247)
at org.apache.spark.rdd.RDD$$anonfun$mapPartitionsInternal$1$$anonfun$apply$24.apply(RDD.scala:858)
at org.apache.spark.rdd.RDD$$anonfun$mapPartitionsInternal$1$$anonfun$apply$24.apply(RDD.scala:858)
at org.apache.spark.rdd.MapPartitionsRDD.compute(MapPartitionsRDD.scala:52)
at org.apache.spark.rdd.RDD.computeOrReadCheckpoint(RDD.scala:346)
at org.apache.spark.rdd.RDD.iterator(RDD.scala:310)
at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:90)
at org.apache.spark.scheduler.Task.run(Task.scala:123)
at org.apache.spark.executor.Executor$TaskRunner$$anonfun$10.apply(Executor.scala:408)
at org.apache.spark.util.Utils$.tryWithSafeFinally(Utils.scala:1360)
at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:414)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
```
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] rdblue commented on pull request #1077: Fix NPE when counting entries
Posted by GitBox <gi...@apache.org>.
rdblue commented on pull request #1077:
URL: https://github.com/apache/iceberg/pull/1077#issuecomment-647636443
After looking at this again, I don't think this should do any projection. From my last comment:
> I think the solution is to remove the project(fileSchema) call after ManifestFiles.read because data tasks should return an unprojected record.
Data tasks should not project data, so this should ignore attempted projection.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] waterlx commented on pull request #1077: Fix NPE when counting entries
Posted by GitBox <gi...@apache.org>.
waterlx commented on pull request #1077:
URL: https://github.com/apache/iceberg/pull/1077#issuecomment-646932877
@rdblue Yes, I will work on it during the weekend.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] rdblue closed pull request #1077: Fix NPE when counting entries
Posted by GitBox <gi...@apache.org>.
rdblue closed pull request #1077:
URL: https://github.com/apache/iceberg/pull/1077
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] waterlx closed pull request #1077: Fix NPE when counting entries
Posted by GitBox <gi...@apache.org>.
waterlx closed pull request #1077:
URL: https://github.com/apache/iceberg/pull/1077
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] waterlx closed pull request #1077: Fix NPE when counting entries
Posted by GitBox <gi...@apache.org>.
waterlx closed pull request #1077:
URL: https://github.com/apache/iceberg/pull/1077
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] waterlx edited a comment on pull request #1077: Fix NPE when counting entries
Posted by GitBox <gi...@apache.org>.
waterlx edited a comment on pull request #1077:
URL: https://github.com/apache/iceberg/pull/1077#issuecomment-636017299
When calling `count()` on entries, Spark passes newRequestedSchema (with size = 0) to Reader#pruneColumns(). As a result, a wrong schema (empty) is generated by Reader#lazySchema().
Schema#lazyNameToId() returns an empty BiMap. get() from this empty map return null. NPE is thrown when trying to convert the null interger into int as the input to findType().
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] waterlx edited a comment on pull request #1077: Fix NPE when counting entries
Posted by GitBox <gi...@apache.org>.
waterlx edited a comment on pull request #1077:
URL: https://github.com/apache/iceberg/pull/1077#issuecomment-636478762
@rdblue The PR is updated.
The following code you suggested
```
Schema fileSchema = fileProjection != null ? new Schema(fileProjection.asStructType().fields()) new Schema();
```
is updated as
```
Schema fileSchema = fileProjection != null ? new Schema(fileProjection.asStructType().fields()) : null;
```
When meeting the null file projection (yielded by projecting 0 columns), it returns null instead of an empty schema, to address the issue of `Missing required field: data_file` mentioned [here](https://github.com/apache/iceberg/pull/1077#issuecomment-636366663).
The issue is quite weird to me as it does not break the UT while it only happends on my testing with master as local[].
Returning an empty schema seems not work in [BaseManifestReader#projection()](https://github.com/apache/iceberg/blob/201f8bf0e5084daa9fcc1e8418762ecb10967036/core/src/main/java/org/apache/iceberg/BaseManifestReader.java#L237) when setting project as an empty schema.
But fixing it by returning null seems get back to way of not supporting 0 columns.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] rdblue commented on a change in pull request #1077: Fix NPE when counting entries
Posted by GitBox <gi...@apache.org>.
rdblue commented on a change in pull request #1077:
URL: https://github.com/apache/iceberg/pull/1077#discussion_r432717836
##########
File path: spark/src/main/java/org/apache/iceberg/spark/source/Reader.java
##########
@@ -149,7 +149,7 @@
private Schema lazySchema() {
if (schema == null) {
- if (requestedSchema != null) {
+ if (requestedSchema != null && requestedSchema.size() != 0) {
Review comment:
I don't think this is correct. Iceberg should support projecting 0 columns.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] rdblue commented on pull request #1077: Fix NPE when counting entries
Posted by GitBox <gi...@apache.org>.
rdblue commented on pull request #1077:
URL: https://github.com/apache/iceberg/pull/1077#issuecomment-655833626
@waterlx, I tried the approach I suggested and it doesn't seem to match what we do for the file tables. Since this PR is a simple fix, I merged it. Thanks for fix this!
Also, I had to rebase and squash by hand since this was a bit old. That's why it's marked closed instead of merged.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] rdblue commented on pull request #1077: Fix NPE when counting entries
Posted by GitBox <gi...@apache.org>.
rdblue commented on pull request #1077:
URL: https://github.com/apache/iceberg/pull/1077#issuecomment-636205153
Looks like there are two problems. First, `findType` throws a `NullPointerException` if the type isn't found. I think that should check whether the name was found, like this:
```diff
public Type findType(String name) {
Preconditions.checkArgument(!name.isEmpty(), "Invalid column name: (empty)");
- return findType(lazyNameToId().get(name));
+ Integer id = lazyNameToId().get(name);
+ if (id != null) {
+ return findType(id);
+ }
+ return null;
}
```
Second, if the file projection is null, it is still dereferenced. So we need to fix that as well:
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] waterlx commented on pull request #1077: Fix NPE when counting entries
Posted by GitBox <gi...@apache.org>.
waterlx commented on pull request #1077:
URL: https://github.com/apache/iceberg/pull/1077#issuecomment-646983050
@rdblue The PR is updated to yield an empty schema when projecting 0 columns, as you suggested [here](https://github.com/apache/iceberg/pull/1077#issuecomment-636205153),
becuase after the PR is rebased according to the most recent master branch, I could not re-produce the following error as mentioned [here](https://github.com/apache/iceberg/pull/1077#issuecomment-636366663):
```java.lang.IllegalArgumentException: Missing required field: data_file```
The problem may be due to that I read a wrong manifest or a manifest generated by the un-completely-merged/rebased code. Thanks for sharing your thought on that! Really appreciate it!
Would you please help to review the curent changes at your most convenience? Thanks!
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] waterlx edited a comment on pull request #1077: Fix NPE when counting entries
Posted by GitBox <gi...@apache.org>.
waterlx edited a comment on pull request #1077:
URL: https://github.com/apache/iceberg/pull/1077#issuecomment-636478762
@rdblue The PR is updated.
The following code you suggested
```
Schema fileSchema = fileProjection != null ? new Schema(fileProjection.asStructType().fields()) new Schema();
```
is updated as
```
Schema fileSchema = fileProjection != null ? new Schema(fileProjection.asStructType().fields()) : null;
```
When meeting the null file projection (yielded by projecting 0 columns), it returns null instead of an empty schema, to address the issue of `Missing required field: data_file` mentioned [here](https://github.com/apache/iceberg/pull/1077#issuecomment-636366663). The issue is quite weird to me as it does not break the UT while it only happends on my local test with master as local[].
Returning an empty schema seems not work as expected in [BaseManifestReader#projection()](https://github.com/apache/iceberg/blob/201f8bf0e5084daa9fcc1e8418762ecb10967036/core/src/main/java/org/apache/iceberg/BaseManifestReader.java#L237) when setting project as an empty schema.
But fixing it by returning null seems get back to way of not supporting 0 columns.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] waterlx edited a comment on pull request #1077: Fix NPE when counting entries
Posted by GitBox <gi...@apache.org>.
waterlx edited a comment on pull request #1077:
URL: https://github.com/apache/iceberg/pull/1077#issuecomment-636478762
@rdblue The PR is updated.
The following code you suggested
```
Schema fileSchema = fileProjection != null ? new Schema(fileProjection.asStructType().fields()) new Schema();
```
is updated as
```
Schema fileSchema = fileProjection != null ? new Schema(fileProjection.asStructType().fields()) : null;
```
When meeting the null file projection (yielded by projecting 0 columns), it returns null instead of an empty schema, to address the issue of `Missing required field: data_file`.
The issue is quite weird to me as it does not break the UT while it only happends on my tesing with master as local[].
Returning an empty schema seems not work in [BaseManifestReader#projection()](https://github.com/apache/iceberg/blob/201f8bf0e5084daa9fcc1e8418762ecb10967036/core/src/main/java/org/apache/iceberg/BaseManifestReader.java#L237) when setting project as an empty schema.
But fixing it by returning null seems get back to way of not supporting 0 columns.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] rdblue commented on pull request #1077: Fix NPE when counting entries
Posted by GitBox <gi...@apache.org>.
rdblue commented on pull request #1077:
URL: https://github.com/apache/iceberg/pull/1077#issuecomment-646895105
@waterlx, do you want to update this PR?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] waterlx commented on pull request #1077: Fix NPE when counting entries
Posted by GitBox <gi...@apache.org>.
waterlx commented on pull request #1077:
URL: https://github.com/apache/iceberg/pull/1077#issuecomment-636478762
@rdblue The PR is updated.
The following code
```
Schema fileSchema = fileProjection != null ? new Schema(fileProjection.asStructType().fields()) new Schema();
```
is updated as
```
Schema fileSchema = fileProjection != null ? new Schema(fileProjection.asStructType().fields()) : null;
```
When meeting the null file projection (yielded by projecting 0 columns), it returns null instead of an empty schema, to address the issue of `Missing required field: data_file`.
The issue is quite weird to me as it does not break the UT while it only happends on my tesing with master as local[].
Returning an empty schema seems not work in [BaseManifestReader#projection()](https://github.com/apache/iceberg/blob/201f8bf0e5084daa9fcc1e8418762ecb10967036/core/src/main/java/org/apache/iceberg/BaseManifestReader.java#L237) when setting project as an empty schema.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] waterlx commented on pull request #1077: Fix NPE when counting entries
Posted by GitBox <gi...@apache.org>.
waterlx commented on pull request #1077:
URL: https://github.com/apache/iceberg/pull/1077#issuecomment-636017685
@rdblue @jerryshao Would you please help to review this PR at your convenience?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] waterlx edited a comment on pull request #1077: Fix NPE when counting entries
Posted by GitBox <gi...@apache.org>.
waterlx edited a comment on pull request #1077:
URL: https://github.com/apache/iceberg/pull/1077#issuecomment-636478762
@rdblue The PR is updated.
The following code you suggested
```
Schema fileSchema = fileProjection != null ? new Schema(fileProjection.asStructType().fields()) new Schema();
```
is updated as
```
Schema fileSchema = fileProjection != null ? new Schema(fileProjection.asStructType().fields()) : null;
```
When meeting the null file projection (yielded by projecting 0 columns), it returns null instead of an empty schema, to address the issue of `Missing required field: data_file` mentioned [here](https://github.com/apache/iceberg/pull/1077#issuecomment-636366663).
The issue is quite weird to me as it does not break the UT while it only happends on my local test with master as local[].
Returning an empty schema seems not work in [BaseManifestReader#projection()](https://github.com/apache/iceberg/blob/201f8bf0e5084daa9fcc1e8418762ecb10967036/core/src/main/java/org/apache/iceberg/BaseManifestReader.java#L237) when setting project as an empty schema.
But fixing it by returning null seems get back to way of not supporting 0 columns.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] waterlx edited a comment on pull request #1077: Fix NPE when counting entries
Posted by GitBox <gi...@apache.org>.
waterlx edited a comment on pull request #1077:
URL: https://github.com/apache/iceberg/pull/1077#issuecomment-636017685
@rdblue @jerryshao Would you please help to review this PR at your convenience?
Regarding UT, I made a separate line to trigger the NPE
```
long actualCount = actual.count()
```
It could be moved into the assert clause at the end, but IMHO a separate line might make it more clear and straightforward
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] waterlx edited a comment on pull request #1077: Fix NPE when counting entries
Posted by GitBox <gi...@apache.org>.
waterlx edited a comment on pull request #1077:
URL: https://github.com/apache/iceberg/pull/1077#issuecomment-636478762
@rdblue The PR is updated.
The following code you suggested
```
Schema fileSchema = fileProjection != null ? new Schema(fileProjection.asStructType().fields()) new Schema();
```
is updated as
```
Schema fileSchema = fileProjection != null ? new Schema(fileProjection.asStructType().fields()) : null;
```
When meeting the null file projection (yielded by projecting 0 columns), it returns null instead of an empty schema, to address the issue of `Missing required field: data_file` mentioned [here](https://github.com/apache/iceberg/pull/1077#issuecomment-636366663). The issue is quite weird to me as it does not break the UT while it only happends on my local test with master as local[].
Returning an empty schema seems not work in [BaseManifestReader#projection()](https://github.com/apache/iceberg/blob/201f8bf0e5084daa9fcc1e8418762ecb10967036/core/src/main/java/org/apache/iceberg/BaseManifestReader.java#L237) when setting project as an empty schema.
But fixing it by returning null seems get back to way of not supporting 0 columns.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] waterlx edited a comment on pull request #1077: Fix NPE when counting entries
Posted by GitBox <gi...@apache.org>.
waterlx edited a comment on pull request #1077:
URL: https://github.com/apache/iceberg/pull/1077#issuecomment-636478762
@rdblue The PR is updated.
The following code you suggested
```
Schema fileSchema = fileProjection != null ? new Schema(fileProjection.asStructType().fields()) new Schema();
```
is updated as
```
Schema fileSchema = fileProjection != null ? new Schema(fileProjection.asStructType().fields()) : null;
```
When meeting the null file projection (yielded by projecting 0 columns), it returns null instead of an empty schema, to address the issue of `Missing required field: data_file` mentioned [here](https://github.com/apache/iceberg/pull/1077#issuecomment-636366663).
The issue is quite weird to me as it does not break the UT while it only happends on my tesing with master as local[].
Returning an empty schema seems not work in [BaseManifestReader#projection()](https://github.com/apache/iceberg/blob/201f8bf0e5084daa9fcc1e8418762ecb10967036/core/src/main/java/org/apache/iceberg/BaseManifestReader.java#L237) when setting project as an empty schema.
But fixing it by returning null seems get back to way of not supporting 0 columns.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] rdblue commented on pull request #1077: Fix NPE when counting entries
Posted by GitBox <gi...@apache.org>.
rdblue commented on pull request #1077:
URL: https://github.com/apache/iceberg/pull/1077#issuecomment-639646385
Part of the problem is that we changed this table over to use a `DataTask`, which provides the data as an iterable instead of reading a data file. The purpose was to correctly set sequence numbers, part of #951. Rows returned by `DataTask` should be full rows, not projections. That's probably why we're hitting this now.
As for why you're getting the current error, I'm not sure why your manifest doesn't have the `data_file` field. It looks like it should work to me, but I can't debug it because I don't have the rest of the test case.
Anyway, I think the solution is to remove the `project(fileSchema)` call after `ManifestFiles.read` because data tasks should return an unprojected record.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] rdblue edited a comment on pull request #1077: Fix NPE when counting entries
Posted by GitBox <gi...@apache.org>.
rdblue edited a comment on pull request #1077:
URL: https://github.com/apache/iceberg/pull/1077#issuecomment-636205153
Looks like there are two problems. First, `findType` throws a `NullPointerException` if the type isn't found. I think that should check whether the name was found, like this:
```diff
public Type findType(String name) {
Preconditions.checkArgument(!name.isEmpty(), "Invalid column name: (empty)");
- return findType(lazyNameToId().get(name));
+ Integer id = lazyNameToId().get(name);
+ if (id != null) {
+ return findType(id);
+ }
+ return null;
}
```
Second, if the file projection is null, it is still dereferenced. So we need to fix that as well in `ManifestEntriesTable`:
```diff
protected CloseableIterable<FileScanTask> planFiles(
TableOperations ops, Snapshot snapshot, Expression rowFilter, boolean caseSensitive, boolean colStats) {
CloseableIterable<ManifestFile> manifests = CloseableIterable.withNoopClose(snapshot.manifests());
- Schema fileSchema = new Schema(schema().findType("data_file").asStructType().fields());
+ Type fileProjection = schema().findType("data_file");
+ Schema fileSchema = fileProjection != null ? new Schema(fileProjection.asStructType().fields()) : new Schema();
String schemaString = SchemaParser.toJson(schema());
String specString = PartitionSpecParser.toJson(PartitionSpec.unpartitioned());
ResidualEvaluator residuals = ResidualEvaluator.unpartitioned(rowFilter);
```
After that, adding this to the entries table test case works:
```
Assert.assertEquals("Count should return 1",
1, spark.read().format("iceberg").load(loadLocation(tableIdentifier, "entries")).count());
```
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] waterlx edited a comment on pull request #1077: Fix NPE when counting entries
Posted by GitBox <gi...@apache.org>.
waterlx edited a comment on pull request #1077:
URL: https://github.com/apache/iceberg/pull/1077#issuecomment-636478762
@rdblue The PR is updated.
The following code
```
Schema fileSchema = fileProjection != null ? new Schema(fileProjection.asStructType().fields()) new Schema();
```
is updated as
```
Schema fileSchema = fileProjection != null ? new Schema(fileProjection.asStructType().fields()) : null;
```
When meeting the null file projection (yielded by projecting 0 columns), it returns null instead of an empty schema, to address the issue of `Missing required field: data_file`.
The issue is quite weird to me as it does not break the UT while it only happends on my tesing with master as local[].
Returning an empty schema seems not work in [BaseManifestReader#projection()](https://github.com/apache/iceberg/blob/201f8bf0e5084daa9fcc1e8418762ecb10967036/core/src/main/java/org/apache/iceberg/BaseManifestReader.java#L237) when setting project as an empty schema.
But fixing it by returning null seems get back to way of not supporting 0 columns.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org