Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
SitdownLiu opened this issue Jun 10, 2022 · 1 comment

Comments

@SitdownLiu
Copy link

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)'
    ]
  }
}
@patxu
Copy link

patxu commented Apr 26, 2024

@SitdownLiu did you ever figure out a solution here? Also having issues getting a response back when using a prepared statement

Edit: my issue was passing PREPARE ... ${query} to prepares rather than just ${query}.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants