How to write a multi-line SQL in logstash pipelines

Hello,

So far, I am able to write a single line SQL in logstash pipelines and it's working fine.

However, How do I write multiline SQL with single-quotes (') in the SQL? I tried with a backslash for continuation, but the pipeline is not being invoked when I look at the logs.

For instance:

How do I write the following sql in pipeline.

Select a.col1,b.col2
from tab1 a, tab2 b
where a.col3='something'
and a.col4=b.col4;

Thanks in advance.

Why do you want to have a multiline SQL?

A string can contain newlines, so I see no reason why something like

statement => "SELECT * from songs
              where artist = :favorite_artist"

would not work.

If the pipeline is not running then logstash almost certainly logged an error. What do you see in the logs?

You're using abind variable. How do I pass values? Can you provide a working example please

Why not just do this?

Select a.col1,b.col2 from tab1 a, tab2 b where a.col3='something' and a.col4=b.col4;

Are you getting an error when you do this?

I guess you want me to type the SQL in a single line... If so, it's not ideal in all situations.

No, I do not care how many lines you spread the SQL across. As I said before, if the pipeline is not running then logstash almost certainly logged an error. What do you see in the logs?

The pipeline is not running because it's multi line. All other pipelines that are single line SQL are running fine

Last chance... what do you see in the logs?

Sorry My friend. Was busy with some other issue.

Thanks. I was able to figure out the issue.

Maybe useful for someone in the future...

I left the index_type and document_type the same and just changed the id in the pipeline. The first pipeline has multisql, the one that followed had a single line.

So I think it was getting overwritten. So I did not see any errors also.
Upon taking a closer look I figured this issue and corrected it.

It worked perfectly. Including predicates with quotes (').

closing the issue.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.