"Macro in the filename of Read Database"
Hi everyone,
I want to use macro value (for example, macroName = query_path, macro_value = C:/Files/query1.sql) in the query file name of Read Database operator as that path is dynamic. So I put %{query_path} to the query file. And it does work giving me the following error:
---------------------------
Cannot read file
'C:\Users\myUser\query_path' - please notice it doesn't use macro value, only parsing macro name as a string
---------------------------
If filename starts from C:/ and then we add macro value (for example, query_path = Files/query1.sql), and query file parameter looks like C:/%{query_path } it works.
However, I need to specify full dynamic path to run my process with no changes on linux and windows.
Could you advise please, how to resolve?
PS: I also tried to use eval() and put macro name in "", it didn't help.
Answers
hello @yelena_kro - good to have you here. That's a weird one. I use macros in my filenames (normal files, not SQL) all the time but I use a Mac. Have you tried using Generate Macro and creating the whole file path as a new macro with concat? And is there a reason you're just not creating a database connection with your SQL database and going that route?
Scott
Hi Scott, thank you for your reply.
I generate macro query_path and use the full path. It doesn't work, pls refer to my previous post. You can see that RapidMiner uses some weired path and doesn't translate macro in that case.
When I take the same path with NO macro, everything works. OR when I start filename from the path (C:/), it also works. So there is no issues with file or connection.
I also use the same macro path, but with different operator (for ex., ReadExcel) and it works. It doesn't work only in the Read Database operator.
Sorry, I didn't get your last question. I am creating predefined DB connection, it works fine.
hello @yelena_kro - can you please paste your process XML in this thread using the </> tool? That will make things a lot easier.
Scott
Scott, I wanted to create small simple example for you to replicate the issue as my actual process is large and contains a number of sub-processes. And I noticed that I had missed '%' sign when defined query_path macro for the sub-process containing Read Database... :smileymad: My bad... Thank you for your help though!
haha no problem @yelena_kro. Glad you found the problem. Feel free to post here again any time.
Scott