Skip to content

Unable to configure SQL preprocessing using 'prepares'. "message: 'Prepared statement not found: query0'" #63

Description

@SitdownLiu

Has anyone encountered a similar problem?

This is my code :

    this.trino.execute({
      query: "EXECUTE query0 USING TIMESTAMP'2022-05-14 00:00:00',TIMESTAMP'2022-05-17 00:00:00'",
      prepares: ['select * from localdevmysql217.binglog.appointmentindex_202108 where between ? and ?'],
      state: function (error, query_id, stats) {
        console.log({ message: 'status changed', id: query_id, stats: stats });
      },
      columns: function (error, data) {
        console.log({ resultColumns: JSON.stringify(data) });
      },
      data: function (error, data, columns, stats) {
        console.log('data: ', data);
      },
      success: function (error, stats) {
        console.log(stats);
      },
      error: function (error) {
        console.log(error);
      },
    });

This is the return result:

{
  message: 'Prepared statement not found: query0',
  errorCode: 5,
  errorName: 'NOT_FOUND',
  errorType: 'USER_ERROR',
  failureInfo: {
    type: 'io.trino.spi.TrinoException',
    message: 'Prepared statement not found: query0',
    suppressed: [],
    stack: [
      'io.trino.util.Failures.checkCondition(Failures.java:64)',
      'io.trino.Session.getPreparedStatement(Session.java:277)',
      'io.trino.Session.getPreparedStatementFromExecute(Session.java:271)',
      'io.trino.execution.QueryPreparer.prepareQuery(QueryPreparer.java:65)',
      'io.trino.execution.QueryPreparer.prepareQuery(QueryPreparer.java:56)',
      'io.trino.dispatcher.DispatchManager.createQueryInternal(DispatchManager.java:180)',
      'io.trino.dispatcher.DispatchManager.lambda$createQuery$0(DispatchManager.java:149)',
      'io.trino.$gen.Trino_375____20220520_013819_2.run(Unknown Source)',
      'java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)',
      'java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)',
      'java.base/java.lang.Thread.run(Thread.java:829)'
    ]
  }
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions