1

MongoDB 使用DBRefs从一个文档到另一个文档的引用(类似于外键),这些就像具有两部分的其他属性,它们引用的集合的名称($ref)和它们引用Id的文档的名称($id)。

它们都以 开头$,查询集合时不会自动拾取这些 DBRef。

我在_schema集合中手动定义它们,如下所示:

{
        "name" : "otherCollection",
        "type" : "row($id ObjectId, $ref varchar)",
        "hidden" : false
}

但它在查询时抛出异常。我正在使用 PrestoDB v0.232,但计划迁移到 PrestoSQL。

2020-03-12T20:56:32.164-0600    ERROR   remote-task-callback-7  com.facebook.presto.execution.StageExecutionStateMachine    Stage execution 20200313_025632_00008_hnu22.2.0 failed
com.google.common.util.concurrent.UncheckedExecutionException: java.lang.IllegalArgumentException: Bad type signature: 'row($id ObjectId)'
    at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2050)
    at com.google.common.cache.LocalCache.get(LocalCache.java:3952)
    at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3974)
    at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4958)
    at com.google.common.cache.LocalCache$LocalLoadingCache.getUnchecked(LocalCache.java:4964)
    at com.facebook.presto.mongodb.MongoSession.getTable(MongoSession.java:153)
    at com.facebook.presto.mongodb.MongoMetadata.getTableMetadata(MongoMetadata.java:278)
    at com.facebook.presto.mongodb.MongoMetadata.listTableColumns(MongoMetadata.java:130)
    at com.facebook.presto.metadata.MetadataManager.listTableColumns(MetadataManager.java:590)
    at com.facebook.presto.metadata.MetadataListing.listTableColumns(MetadataListing.java:93)
    at com.facebook.presto.connector.system.jdbc.ColumnJdbcTable.cursor(ColumnJdbcTable.java:126)
    at com.facebook.presto.connector.system.SystemPageSourceProvider$1.cursor(SystemPageSourceProvider.java:124)
    at com.facebook.presto.split.MappedRecordSet.cursor(MappedRecordSet.java:53)
    at com.facebook.presto.spi.RecordPageSource.<init>(RecordPageSource.java:38)
    at com.facebook.presto.connector.system.SystemPageSourceProvider.createPageSource(SystemPageSourceProvider.java:103)
    at com.facebook.presto.spi.connector.ConnectorPageSourceProvider.createPageSource(ConnectorPageSourceProvider.java:40)
    at com.facebook.presto.split.PageSourceManager.createPageSource(PageSourceManager.java:58)
    at com.facebook.presto.operator.ScanFilterAndProjectOperator.getOutput(ScanFilterAndProjectOperator.java:227)
    at com.facebook.presto.operator.Driver.processInternal(Driver.java:379)
    at com.facebook.presto.operator.Driver.lambda$processFor$8(Driver.java:283)
    at com.facebook.presto.operator.Driver.tryWithLock(Driver.java:675)
    at com.facebook.presto.operator.Driver.processFor(Driver.java:276)
    at com.facebook.presto.execution.SqlTaskExecution$DriverSplitRunner.processFor(SqlTaskExecution.java:1077)
    at com.facebook.presto.execution.executor.PrioritizedSplitRunner.process(PrioritizedSplitRunner.java:162)
    at com.facebook.presto.execution.executor.TaskExecutor$TaskRunner.run(TaskExecutor.java:545)
    at com.facebook.presto.$gen.Presto_0_232_cc1019c____20200313_025536_1.run(Unknown Source)
    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)
Caused by: java.lang.IllegalArgumentException: Bad type signature: 'row($id ObjectId)'
    at com.facebook.presto.spi.type.TypeSignature.checkArgument(TypeSignature.java:360)
    at com.facebook.presto.spi.type.TypeSignature.parseRowTypeSignature(TypeSignature.java:200)
    at com.facebook.presto.spi.type.TypeSignature.parseTypeSignature(TypeSignature.java:119)
    at com.facebook.presto.spi.type.TypeSignature.parseTypeSignature(TypeSignature.java:106)
    at com.facebook.presto.mongodb.MongoSession.buildColumnHandle(MongoSession.java:197)
    at com.facebook.presto.mongodb.MongoSession.loadTableSchema(MongoSession.java:183)
    at com.google.common.cache.CacheLoader$FunctionToCacheLoader.load(CacheLoader.java:165)
    at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3528)
    at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2277)
    at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2154)
    at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2044)
    ... 28 more

有没有办法阅读这些领域?

更新: 我尝试迁移到 PrestoSQL 最新版本 (331) 并使用",如下所示:

"{
        "name" : "otherCollection",
        "type" : "row(\"$id\" ObjectId, \"$ref\" varchar)",
        "hidden" : false
}"

并且该列开始显示在查询中,但内容始终为空。也尝试过,'但在这种情况下得到了这个例外:

java.util.concurrent.ExecutionException: io.prestosql.sql.parser.ParsingException: line 1:5: mismatched input ''$id''. Expecting: <type>
    at com.google.common.util.concurrent.AbstractFuture.getDoneValue(AbstractFuture.java:531)
    at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:492)
    at com.google.common.util.concurrent.AbstractFuture$TrustedFuture.get(AbstractFuture.java:83)
    at com.google.common.util.concurrent.Uninterruptibles.getUninterruptibly(Uninterruptibles.java:196)
    at com.google.common.cache.LocalCache$Segment.getAndRecordStats(LocalCache.java:2312)
    at com.google.common.cache.LocalCache$Segment$1.run(LocalCache.java:2292)
    at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:398)
    at com.google.common.util.concurrent.AbstractFuture.executeListener(AbstractFuture.java:1029)
    at com.google.common.util.concurrent.AbstractFuture.addListener(AbstractFuture.java:675)
    at com.google.common.util.concurrent.AbstractFuture$TrustedFuture.addListener(AbstractFuture.java:105)
    at com.google.common.cache.LocalCache$Segment.loadAsync(LocalCache.java:2287)
    at com.google.common.cache.LocalCache$Segment.refresh(LocalCache.java:2359)
    at com.google.common.cache.LocalCache$Segment.scheduleRefresh(LocalCache.java:2337)
    at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2034)
    at com.google.common.cache.LocalCache.get(LocalCache.java:3952)
    at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3974)
    at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4958)
    at com.google.common.cache.LocalCache$LocalLoadingCache.getUnchecked(LocalCache.java:4964)
    at io.prestosql.plugin.mongodb.MongoSession.getTable(MongoSession.java:164)
    at io.prestosql.plugin.mongodb.MongoMetadata.getColumnHandles(MongoMetadata.java:114)
    at io.prestosql.plugin.mongodb.MongoMetadata.getTableProperties(MongoMetadata.java:226)
    at io.prestosql.metadata.MetadataManager.getTableProperties(MetadataManager.java:415)
    at io.prestosql.sql.planner.DistributedExecutionPlanner.getTableInfo(DistributedExecutionPlanner.java:145)
    at io.prestosql.sql.planner.DistributedExecutionPlanner.lambda$doPlan$0(DistributedExecutionPlanner.java:133)
    at com.google.common.collect.CollectCollectors.lambda$toImmutableMap$1(CollectCollectors.java:61)
    at java.util.stream.ReduceOps$3ReducingSink.accept(ReduceOps.java:169)
    at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
    at java.util.Collections$2.tryAdvance(Collections.java:4719)
    at java.util.Collections$2.forEachRemaining(Collections.java:4727)
    at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482)
    at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)
    at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
    at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
    at io.prestosql.sql.planner.DistributedExecutionPlanner.doPlan(DistributedExecutionPlanner.java:133)
    at io.prestosql.sql.planner.DistributedExecutionPlanner.doPlan(DistributedExecutionPlanner.java:124)
    at io.prestosql.sql.planner.DistributedExecutionPlanner.plan(DistributedExecutionPlanner.java:96)
    at io.prestosql.execution.SqlQueryExecution.planDistribution(SqlQueryExecution.java:433)
    at io.prestosql.execution.SqlQueryExecution.start(SqlQueryExecution.java:339)
    at io.prestosql.$gen.Presto_331____20200318_020345_2.run(Unknown Source)
    at io.prestosql.execution.SqlQueryManager.createQuery(SqlQueryManager.java:240)
    at io.prestosql.dispatcher.LocalDispatchQuery.lambda$startExecution$7(LocalDispatchQuery.java:132)
    at io.prestosql.$gen.Presto_331____20200318_020345_2.run(Unknown Source)
    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)
Caused by: io.prestosql.sql.parser.ParsingException: line 1:5: mismatched input ''$id''. Expecting: <type>
    at io.prestosql.sql.parser.ErrorHandler.syntaxError(ErrorHandler.java:108)
    at org.antlr.v4.runtime.ProxyErrorListener.syntaxError(ProxyErrorListener.java:41)
    at org.antlr.v4.runtime.Parser.notifyErrorListeners(Parser.java:544)
    at org.antlr.v4.runtime.DefaultErrorStrategy.reportNoViableAlternative(DefaultErrorStrategy.java:310)
    at org.antlr.v4.runtime.DefaultErrorStrategy.reportError(DefaultErrorStrategy.java:136)
    at io.prestosql.sql.parser.SqlBaseParser.type(SqlBaseParser.java:10326)
    at io.prestosql.sql.parser.SqlBaseParser.standaloneType(SqlBaseParser.java:386)
    at io.prestosql.sql.parser.SqlParser.invokeParser(SqlParser.java:146)
    at io.prestosql.sql.parser.SqlParser.createType(SqlParser.java:96)
    at io.prestosql.metadata.TypeRegistry.fromSqlType(TypeRegistry.java:164)
    at io.prestosql.metadata.MetadataManager.fromSqlType(MetadataManager.java:1262)
    at io.prestosql.type.InternalTypeManager.fromSqlType(InternalTypeManager.java:51)
    at io.prestosql.plugin.mongodb.MongoSession.buildColumnHandle(MongoSession.java:208)
    at io.prestosql.plugin.mongodb.MongoSession.loadTableSchema(MongoSession.java:194)
    at com.google.common.cache.CacheLoader$FunctionToCacheLoader.load(CacheLoader.java:165)
    at com.google.common.cache.CacheLoader.reload(CacheLoader.java:100)
    at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3531)
    at com.google.common.cache.LocalCache$Segment.loadAsync(LocalCache.java:2286)
    ... 35 more
Caused by: org.antlr.v4.runtime.NoViableAltException
    at org.antlr.v4.runtime.atn.ParserATNSimulator.noViableAlt(ParserATNSimulator.java:2028)
    at org.antlr.v4.runtime.atn.ParserATNSimulator.execATN(ParserATNSimulator.java:467)
    at org.antlr.v4.runtime.atn.ParserATNSimulator.adaptivePredict(ParserATNSimulator.java:393)
    at io.prestosql.sql.parser.SqlBaseParser.type(SqlBaseParser.java:10012)
    ... 47 more
4

0 回答 0