Hello, after migrate to 24.2.6-202311250456170399-68acbe47
we have this error when try create a view using
CREATE OR REPLACE VIEW XXX as SELECT A,B, from T
Note, that this only occur when using odbc flight, we make some debug of dremio and detect that in
com.dremio.exec.util.QueryVersionUtils
in the method checkForUnspecifiedVersionsAndReturnRelNode
inside queryContextForVersionValidation
the line code
private static UserSession userSessionForVersionValidation(SabotContext sabotContext, List<String> pathContext, Map<String, VersionContext> sourceVersionMapping, Optional<UserSession> userSession) {
return userSession.isPresent() ? Builder.newBuilderWithCopy((UserSession)userSession.get()).withDefaultSchema(pathContext).withSourceVersionMapping(sourceVersionMapping).withErrorOnUnspecifiedVersion(true).build() : Builder.newBuilder().withSessionOptionManager(new SessionOptionManagerImpl(sabotContext.getOptionValidatorListing()), sabotContext.getOptionManager()).withDefaultSchema(pathContext).withSourceVersionMapping(sourceVersionMapping).withUserProperties(UserProperties.getDefaultInstance()).withCredentials(UserCredentials.newBuilder().setUserName("$dremio$").build()).withCheckMetadataValidity(false).withNeverPromote(false).withErrorOnUnspecifiedVersion(true).build();
}
is wrong because when Builder.newBuilderWithCopy
method calls this.userSession = new UserSession(session)
but this in UserSession
use this.credentials = userSession.credentials
but when use fligth userSession is an instance of ChangeTrackingUserSession
which extends of extends UserSession
and has credentials
in null because all info of this class is in UserSession delegate
so when create ContextInformationImpl
this line (40) this.queryUser = userCredentials.getUserName()
throws NullPointerException
I think this is a critical error because we cannot run DDL operations using odbc, please @dch or @balaji.ramaswamy your help
log in dremio log file:
com.dremio.common.exceptions.UserException: Validation of view sql failed. null
at com.dremio.common.exceptions.UserException$Builder.build(UserException.java:926)
at com.dremio.common.exceptions.UserException$Builder.buildSilently(UserException.java:993)
at com.dremio.exec.planner.sql.handlers.direct.CreateViewHandler.validateTablesAndVersionContext(CreateViewHandler.java:391)
at com.dremio.exec.planner.sql.handlers.direct.CreateViewHandler.toResult(CreateViewHandler.java:94)
at com.dremio.exec.planner.sql.handlers.commands.DirectCommand.plan(DirectCommand.java:61)
at com.dremio.exec.work.foreman.AttemptManager.plan(AttemptManager.java:571)
at com.dremio.exec.work.foreman.AttemptManager.lambda$run$4(AttemptManager.java:462)
at com.dremio.service.commandpool.ReleasableBoundCommandPool.lambda$getWrappedCommand$3(ReleasableBoundCommandPool.java:140)
at com.dremio.service.commandpool.CommandWrapper.run(CommandWrapper.java:70)
at com.dremio.context.RequestContext.run(RequestContext.java:109)
at com.dremio.common.concurrent.ContextMigratingExecutorService.lambda$decorate$4(ContextMigratingExecutorService.java:226)
at com.dremio.common.concurrent.ContextMigratingExecutorService$ComparableRunnable.run(ContextMigratingExecutorService.java:206)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
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:750)