liquibase/liquibase-cassandra

CREATE FUNCTION with Java code inside

m1imueller opened this issue · 1 comments

Hello,
I try to create a UDF/UDA with liquibase-cassandra, but I have trouble with endDelimiter.

The state function looks like

CREATE OR REPLACE FUNCTION telematik_dev.quantileState (
  state list<double>,
  val double,
  qtl int
) 
  CALLED ON NULL INPUT 
  RETURNS list<double>
  LANGUAGE java AS 
    $$
	if (state!=null && val!=null) {
		if (state.size() ==0){
			state.add(qtl/100d);
		}
	    state.add(val);
	}	
	return state;
    $$
;

So I have create a changeset that looks like

<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xmlns:pro="http://www.liquibase.org/xml/ns/pro" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/pro http://www.liquibase.org/xml/ns/pro/liquibase-pro-3.9.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.9.xsd">

	<changeSet id="2" author="nd060" context="versioning" labels="1.0.1">
		<tagDatabase tag="version_1.0.1" />
	</changeSet>

	<changeSet id="3" author="ne060" labels="1.0.2">
		<comment>Adding quantile state function</comment>
		<sql>
			CREATE OR REPLACE FUNCTION quantileState (state list&lt;double&gt;, val double, qtl int) 
			  CALLED ON NULL INPUT 
			  RETURNS list&lt;double&gt;
			  LANGUAGE java AS 
			    $$
				if (state!=null &amp;&amp; val!=null) {
					if (state.size() ==0){
						state.add(qtl/100d);
					}
				    state.add(val);
				}	
				return state;
			    $$
			;
		</sql>		
	</changeSet>

But execution didn't work because of the ";" inside of the java code block. Is there a way to create UDF/UDA with liquibase-cassandra?

Cheers
Michael