Skip to main content

I’m getting the following exception when trying to run the following code.

Is there a way to enable or set the HTTP Header X-Trino-User?

PrestoConnection connection = new PrestoConnection($"Server={_configurationi"TrinoServerIP"]};Port={_configurationi"TrinoServerPort"]};");

connection.Open();

string sql = "SELECT * FROM hive.default.customer";

PrestoCommand cmd = new PrestoCommand(sql, connection);

PrestoDataReader rdr = cmd.ExecuteReader();

while (rdr.Read())
{
Console.WriteLine(String.Format("\t{0} --> \t\t{1}", rdrr"Id"], rdrr"Name"]));
}
 PrestoAdo
 Source: TrinoClientTests.cs line 91
 Duration: 1.4 sec

Message: 
Test method Juniper.Test.Trino.TrinoClientTests.PrestoAdo threw exception:
System.Data.CData.Presto.PrestoException: o500] Could not execute the specified command: HTTP protocol error. 401 Basic authentication or X-Trino-User must be sent. ---> oro230j.TC: HTTP protocol error. 401 Basic authentication or X-Trino-User must be sent.

Stack Trace: 
LdJ.j(Laxc] , Int32 , Int32 )
LdJ.n()
RUC.Nd()
RUx.Nd()
RTG.a(RUx )
RTN.FJ()
RTG.NS()
KJ.U(SQLQuery , Int32 , RRq )
KJ.d(IDataStatement , SQLQuery , QueryParameterCollection , Int32 , String , LeW )
RUJ.ExecuteQuery(IDataStatement , QueryParameterCollection , Int32 )
RUG.ExecuteQuery(IDataStatement , QueryParameterCollection , Int32 )
LTx.ExecuteQuery(IDataStatement , QueryParameterCollection , Int32 )
ZW.ExecuteQuery(IDataStatement , QueryParameterCollection , Int32 )
yN.ExecuteQuery(IDataStatement , QueryParameterCollection , Int32 )
RIe.FW()
RIh.dd()
SF.pg(QueryParameterCollection )
PrestoCommand.ExecuteDataReader(CommandBehavior behavior)
--- End of inner exception stack trace ---
PrestoCommand.ExecuteDataReader(CommandBehavior behavior)
PrestoCommand.ExecuteDbDataReader(CommandBehavior behavior)
PrestoCommand.ExecuteReader()
<PrestoAdo>d__5.MoveNext() line 104
--- End of stack trace from previous location where exception was thrown ---
ExceptionDispatchInfo.Throw()
TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
ThreadOperations.ExecuteWithAbortSafety(Action action)

 

This is most likely happening due to you trying to connect to a Trino instance with the driver default settings configured to access a Presto database instead.

Since you are using Trino and not PrestoDB, it will be important to ensure you have adjusted the 'PrestoKind' property to 'Trino'. Find more information on the property here:

https://cdn.cdata.com/help/ORJ/ado/RSBPresto_p_PrestoKind.htm 

Setting the property should resolve the problem. In case you have any other questions or issues feel free to send those over at [email protected] or you can always submit a support case here.


Thanks @Ethem Q...that worked!


Reply