[ 
https://issues.apache.org/jira/browse/DRILL-5088?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15820475#comment-15820475
 ] 

ASF GitHub Bot commented on DRILL-5088:
---------------------------------------

Github user chunhui-shi commented on the issue:

    https://github.com/apache/drill/pull/702
  
    MongoGroupScan tries to read first record to guess record width. So this 
toJson is called for only first record.
    
    Notice that MongoClient.getDefaultCodecRegistry() contains 
DBRefCodecProvider:
    
    Shown in MongoClient.java(In MongoClient.java):
    
        private static final CodecRegistry DEFAULT_CODEC_REGISTRY =
                fromProviders(asList(new ValueCodecProvider(),
                        new DBRefCodecProvider(),
                        new DocumentCodecProvider(new 
DocumentToDBRefTransformer()),
                        new DBObjectCodecProvider(),
                        new BsonValueCodecProvider(),
                        new GeoJsonCodecProvider()));
    
    but a default DocumentCodec constructor does not. And it was this 
constructor get called if we don't set a codec for toJson function to use. The 
list of CodecProviders is shown in DocumentCodec.java in MongoDb's code:
    
    public class DocumentCodec implements CollectibleCodec<Document> {
    
        private static final String ID_FIELD_NAME = "_id";
        private static final CodecRegistry DEFAULT_REGISTRY = 
fromProviders(asList(new ValueCodecProvider(),
                new BsonValueCodecProvider(),
                new DocumentCodecProvider()));



> Error when reading DBRef column
> -------------------------------
>
>                 Key: DRILL-5088
>                 URL: https://issues.apache.org/jira/browse/DRILL-5088
>             Project: Apache Drill
>          Issue Type: Bug
>          Components: Execution - Data Types
>         Environment: drill 1.9.0
> mongo 3.2
>            Reporter: Guillaume Champion
>            Assignee: Chunhui Shi
>
> In a mongo database with DBRef, when a DBRef is inserted in the first line of 
> a mongo's collection drill query failed :
> {code}
> 0: jdbc:drill:zk=local> select * from mongo.mydb.contact2;
> Error: SYSTEM ERROR: CodecConfigurationException: Can't find a codec for 
> class com.mongodb.DBRef.
> {code}
> Simple example to reproduce:
> In mongo instance
> {code}
> db.contact2.drop();
> db.contact2.insert({ "_id" : ObjectId("582081d96b69060001fd8938"), "account" 
> : DBRef("contact", ObjectId("999cbf116b69060001fd8611")) });
> {code}
> In drill :
> {code}
> 0: jdbc:drill:zk=local> select * from mongo.mydb.contact2;
> Error: SYSTEM ERROR: CodecConfigurationException: Can't find a codec for 
> class com.mongodb.DBRef.
> [Error Id: 2944d766-e483-4453-a706-3d481397b186 on Analytics-Biznet:31010] 
> (state=,code=0)
> {code}
> If the first line doesn't contain de DBRef, drill will querying correctly :
> In a mongo instance :
> {code}
> db.contact2.drop();
> db.contact2.insert({ "_id" : ObjectId("582081d96b69060001fd8939") });
> db.contact2.insert({ "_id" : ObjectId("582081d96b69060001fd8938"), "account" 
> : DBRef("contact", ObjectId("999cbf116b69060001fd8611")) });
> {code}
> In drill :
> {code}
> 0: jdbc:drill:zk=local> select * from mongo.mydb.contact2;
> +--------------------------------------+---------------------------------------------------------------+
> |                 _id                  |                            account   
>                          |
> +--------------------------------------+---------------------------------------------------------------+
> | {"$oid":"582081d96b69060001fd8939"}  | {"$id":{}}                           
>                          |
> | {"$oid":"582081d96b69060001fd8938"}  | 
> {"$ref":"contact","$id":{"$oid":"999cbf116b69060001fd8611"}}  |
> +--------------------------------------+---------------------------------------------------------------+
> 2 rows selected (0,563 seconds)
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to