databasetime-seriesquestdb

"Error - Constant Expected" when I do an IN subquery


When I try to execute this query I am getting ERROR: constant expected

  type, file, function, line, caller_file, caller_function, caller_line, note, error, duration, timestamp,
  application, entity, customer, host, request_method, response_status, city, country, request_path, username, role
from webapm where id in (select id as apm_id
                         from webapm 
                         where type is null
                         order by timestamp desc
                         limit 100);

But it works when I manually type a list of values, as in

select id,
  type, file, function, line, caller_file, caller_function, caller_line, note, error, duration, timestamp,
  application, entity, customer, host, request_method, response_status, city, country, request_path, username, role
from webapm
where id in (
'680ab5d32d9adb567c06c800',
'680ab4a92d9adb567c06c7fd',
'680ab37d2d9adb567c06c7fa',
'680ab2512d9adb567c06c7f7',
'680ab124af17eec2e8011809',
'680aaff82d9adb567c06c7f4',
'680aaecdaf17eec2e8011806',
'680aae21af17eec2e8011803',
'680aada32d9adb567c06c7f1',
'680aacf42d9adb567c06c7ee'
)
order by timestamp;

Why am I getting the error? Is there any way to dynamically build that list of id values (basically what I was trying to do with the join)? Playing around with string_agg and potentially combining with replace string functions. Have not got it working, but let me know if that is a workable option.


Solution

  • Scalar queries are supported in QuestDB only for Symbols and timestamps.