grvGarg
(Gourav Garg)
August 1, 2022, 4:00pm
1
Hi
I am using jdbc_streaming plugin. I have a complex query and also my postgres required double quotes (") with each table/column name.
I am also using Case When in my query, which requires apostrophe(').
Plugin does not support statement file path and if I use escape character() it give me error that query exception.
jdbc_streaming {
jdbc_driver_library => "${LOGSTASH_JDBC_DRIVER_JAR_LOCATION}"
jdbc_driver_class => "org.postgresql.Driver"
jdbc_connection_string => "${LOGSTASH_JDBC_URL}"
jdbc_user => "${LOGSTASH_JDBC_USERNAME}"
jdbc_password => "${LOGSTASH_JDBC_PASSWORD}"
statement => ' select
"ClosedDealId" as "closedDealId"
, CASE WHEN "IsCpo" = true then \'Certified Pre-owned\'
when ("IsCpo" = false or "IsCpo" = null) and "IsNew" = true then \'New\'
ELSE\ 'N/A\' END AS "vehicleType"
from dbo."ReplacementDeal"'
target => "replacementDeal"
}
Can anyone help me?
You are not escaping that single quote in there (note the space):
ELSE\ 'N/A\' END AS "vehicleType"
it should be:
ELSE \'N/A\' END AS "vehicleType"
grvGarg
(Gourav Garg)
August 2, 2022, 9:22am
3
Oh sorry, this is just here while doing formatting it happened but issue still exist.
jdbc_streaming {
jdbc_driver_library => "${LOGSTASH_JDBC_DRIVER_JAR_LOCATION}"
jdbc_driver_class => "org.postgresql.Driver"
jdbc_connection_string => "${LOGSTASH_JDBC_URL}"
jdbc_user => "${LOGSTASH_JDBC_USERNAME}"
jdbc_password => "${LOGSTASH_JDBC_PASSWORD}"
statement => ' select
"ClosedDealId" as "closedDealId"
, CASE WHEN "IsCpo" = true then \'Certified Pre-owned\'
when ("IsCpo" = false or "IsCpo" = null) and "IsNew" = true then \'New\'
ELSE \'N/A\' END AS "vehicleType"
from dbo."ReplacementDeal"'
target => "replacementDeal"
}
Can you share what error message you are seeing in Logstash?
grvGarg
(Gourav Garg)
August 3, 2022, 3:52am
5
I figured this out. Had to use below configuration in pipeline
config.support_escapes: true
1 Like
system
(system)
Closed
August 31, 2022, 3:52am
6
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.