mneedham opened a new pull request #7792:
URL: https://github.com/apache/pinot/pull/7792


   I had a typo in my schema file where instead of `dataType` I had `type`:
   
   ```
   {
     "dimensionFieldSpecs": [
       {
         "name": "booleanDimension",
         "type": "BOOLEAN",
         "defaultNullValue": false
       }
     ],
     "schemaName": "invalid"
   }
   ```
   
   The error message when trying to add a schema doesn't make it clear what 
mistake has been made:
   
   ```
   2021/11/18 07:40:19.075 ERROR [AddTableCommand] [main] Got exception while 
reading Pinot schema from file: [/config/testschema.json]
   shaded.com.fasterxml.jackson.databind.JsonMappingException: N/A
    at [Source: (File); line: 52, column: 5] (through reference chain: 
org.apache.pinot.spi.data.Schema["dimensionFieldSpecs"])
        at 
shaded.com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:278)
        at 
shaded.com.fasterxml.jackson.databind.deser.SettableBeanProperty._throwAsIOE(SettableBeanProperty.java:611)
        at 
shaded.com.fasterxml.jackson.databind.deser.SettableBeanProperty._throwAsIOE(SettableBeanProperty.java:599)
        at 
shaded.com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:143)
        at 
shaded.com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:288)
        at 
shaded.com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:151)
        at 
shaded.com.fasterxml.jackson.databind.ObjectReader._bindAndClose(ObjectReader.java:1719)
        at 
shaded.com.fasterxml.jackson.databind.ObjectReader.readValue(ObjectReader.java:1310)
        at org.apache.pinot.spi.utils.JsonUtils.fileToObject(JsonUtils.java:92)
        at org.apache.pinot.spi.data.Schema.fromFile(Schema.java:87)
        at 
org.apache.pinot.tools.admin.command.AddTableCommand.uploadSchema(AddTableCommand.java:160)
        at 
org.apache.pinot.tools.admin.command.AddTableCommand.execute(AddTableCommand.java:203)
        at org.apache.pinot.tools.Command.call(Command.java:33)
        at org.apache.pinot.tools.Command.call(Command.java:29)
        at picocli.CommandLine.executeUserObject(CommandLine.java:1953)
        at picocli.CommandLine.access$1300(CommandLine.java:145)
        at 
picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2352)
        at picocli.CommandLine$RunLast.handle(CommandLine.java:2346)
        at picocli.CommandLine$RunLast.handle(CommandLine.java:2311)
        at 
picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2179)
        at picocli.CommandLine.execute(CommandLine.java:2078)
        at 
org.apache.pinot.tools.admin.PinotAdministrator.execute(PinotAdministrator.java:161)
        at 
org.apache.pinot.tools.admin.PinotAdministrator.main(PinotAdministrator.java:192)
   Caused by: java.lang.NullPointerException
        at org.apache.pinot.spi.data.Schema.addField(Schema.java:216)
        at 
org.apache.pinot.spi.data.Schema.setDimensionFieldSpecs(Schema.java:132)
        at 
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at 
java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at 
shaded.com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:141)
        ... 19 more
   ```
   
   This PR checks if `schema.getDataType()` is null before reading it in 
`Schema#addField` and if it's null, will throw an error message that indicates 
where the problem is. The new error message looks like this:
   
   ```
   com.fasterxml.jackson.databind.JsonMappingException: 'booleanDimension' 
field is missing 'dataType' property
    at [Source: (File); line: 8, column: 3] (through reference chain: 
org.apache.pinot.spi.data.Schema["dimensionFieldSpecs"])
   
        at 
com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:278)
        at 
com.fasterxml.jackson.databind.deser.SettableBeanProperty._throwAsIOE(SettableBeanProperty.java:611)
        at 
com.fasterxml.jackson.databind.deser.SettableBeanProperty._throwAsIOE(SettableBeanProperty.java:599)
        at 
com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:143)
        at 
com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:288)
        at 
com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:151)
        at 
com.fasterxml.jackson.databind.ObjectReader._bindAndClose(ObjectReader.java:1719)
        at 
com.fasterxml.jackson.databind.ObjectReader.readValue(ObjectReader.java:1310)
        at org.apache.pinot.spi.utils.JsonUtils.fileToObject(JsonUtils.java:92)
        at org.apache.pinot.spi.data.Schema.fromFile(Schema.java:87)
        at 
org.apache.pinot.common.data.SchemaTest.testMissingDataType(SchemaTest.java:264)
   Caused by: java.lang.UnsupportedOperationException: 'booleanDimension' field 
is missing 'dataType' property
        at org.apache.pinot.spi.data.Schema.addField(Schema.java:217)
        at 
org.apache.pinot.spi.data.Schema.setDimensionFieldSpecs(Schema.java:132)
        at 
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at 
java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at 
com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:141)
        ... 31 more
   ```
   
   I think the user would be able to figure out what they need to fix based on 
that message.


-- 
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-unsubscr...@pinot.apache.org

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



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org
For additional commands, e-mail: commits-h...@pinot.apache.org

Reply via email to