How to correctly write SQL metacode in metaprogramming?

40 views Asked by At

Here is my script:

snap = loadTable("dfs://China_Market_HF", `Market_Snapshot)
select count(*) from snap where Date = 2015.01.15
exec(<select count(*) from snap where Date = 2015.01.15>)

In this script, the SQL statement

select count(*) 
from table 
where d == 2023.10.10

is correct, but I get an error:

Syntax Error: [line #3] FROM clause expected

1

There are 1 answers

0
zhihengqu On BEST ANSWER

In metaprogramming, you should use the eval function to evaluate the given metacode, instead of exec.

eval(<select count(*) from table where d == 2023.10.10>)