Error when create view using odbc Flight

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)

Hello friends, @dch or @balaji.ramaswamy can you check this error please?

Hi @dacopan I will work with the right team but will get to this next week, Thanks, Bali

1 Like

The issue I encountered is indeed identical to the error code mentioned in your post. I encountered the problem while using the DremioFlightEndpoint interface. Thank you for bringing this to my attention. Could you please clarify if there are any limitations regarding JDBC or ODBC interfaces, such as any restrictions on creating views when using DremioFlightEndpoint?"

and the same error in adbc like this : Encounter pyarrow Invalid Parameter Error When Creating View Using Dremio Flight Endpoint - Dremio University - Dremio

This is the ADBC interface I created based on the documentation I referred to. : arrow-flight-client-examples/python at main · dremio-hub/arrow-flight-client-examples (github.com)

@Han-lai we not received a responde about this error, but my solution was donwngrade to a past version, that not have this issue

Thank you for your response, I would like to ask, which version of Dremio are you using to create views with the ADBC Flight?

In 24.1.0 is the last version that I tested creating views, more recent versions of it not work