summaryrefslogtreecommitdiffstats
path: root/src/arrow/c_glib/test/gandiva
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:54:28 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:54:28 +0000
commite6918187568dbd01842d8d1d2c808ce16a894239 (patch)
tree64f88b554b444a49f656b6c656111a145cbbaa28 /src/arrow/c_glib/test/gandiva
parentInitial commit. (diff)
downloadceph-e6918187568dbd01842d8d1d2c808ce16a894239.tar.xz
ceph-e6918187568dbd01842d8d1d2c808ce16a894239.zip
Adding upstream version 18.2.2.upstream/18.2.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/arrow/c_glib/test/gandiva')
-rw-r--r--src/arrow/c_glib/test/gandiva/test-binary-literal-node.rb47
-rw-r--r--src/arrow/c_glib/test/gandiva/test-boolean-literal-node.rb32
-rw-r--r--src/arrow/c_glib/test/gandiva/test-boolean-node.rb38
-rw-r--r--src/arrow/c_glib/test/gandiva/test-condition.rb35
-rw-r--r--src/arrow/c_glib/test/gandiva/test-double-literal-node.rb32
-rw-r--r--src/arrow/c_glib/test/gandiva/test-expression.rb46
-rw-r--r--src/arrow/c_glib/test/gandiva/test-field-node.rb37
-rw-r--r--src/arrow/c_glib/test/gandiva/test-filter.rb51
-rw-r--r--src/arrow/c_glib/test/gandiva/test-float-literal-node.rb32
-rw-r--r--src/arrow/c_glib/test/gandiva/test-function-node.rb43
-rw-r--r--src/arrow/c_glib/test/gandiva/test-function-registry.rb45
-rw-r--r--src/arrow/c_glib/test/gandiva/test-function-signature.rb101
-rw-r--r--src/arrow/c_glib/test/gandiva/test-if-node.rb49
-rw-r--r--src/arrow/c_glib/test/gandiva/test-int16-literal-node.rb32
-rw-r--r--src/arrow/c_glib/test/gandiva/test-int32-literal-node.rb32
-rw-r--r--src/arrow/c_glib/test/gandiva/test-int64-literal-node.rb32
-rw-r--r--src/arrow/c_glib/test/gandiva/test-int8-literal-node.rb32
-rw-r--r--src/arrow/c_glib/test/gandiva/test-native-function.rb132
-rw-r--r--src/arrow/c_glib/test/gandiva/test-null-literal-node.rb38
-rw-r--r--src/arrow/c_glib/test/gandiva/test-projector.rb63
-rw-r--r--src/arrow/c_glib/test/gandiva/test-selectable-projector.rb74
-rw-r--r--src/arrow/c_glib/test/gandiva/test-selection-vector.rb42
-rw-r--r--src/arrow/c_glib/test/gandiva/test-string-literal-node.rb32
-rw-r--r--src/arrow/c_glib/test/gandiva/test-uint16-literal-node.rb32
-rw-r--r--src/arrow/c_glib/test/gandiva/test-uint32-literal-node.rb32
-rw-r--r--src/arrow/c_glib/test/gandiva/test-uint64-literal-node.rb32
-rw-r--r--src/arrow/c_glib/test/gandiva/test-uint8-literal-node.rb32
27 files changed, 1225 insertions, 0 deletions
diff --git a/src/arrow/c_glib/test/gandiva/test-binary-literal-node.rb b/src/arrow/c_glib/test/gandiva/test-binary-literal-node.rb
new file mode 100644
index 000000000..fddf74830
--- /dev/null
+++ b/src/arrow/c_glib/test/gandiva/test-binary-literal-node.rb
@@ -0,0 +1,47 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+class TestGandivaBinaryLiteralNode < Test::Unit::TestCase
+ def setup
+ omit("Gandiva is required") unless defined?(::Gandiva)
+ @value = "\x00\x01\x02\x03\x04"
+ end
+
+ sub_test_case(".new") do
+ def test_string
+ node = Gandiva::BinaryLiteralNode.new(@value)
+ assert_equal(@value, node.value.to_s)
+ end
+
+ def test_bytes
+ bytes_value = GLib::Bytes.new(@value)
+ node = Gandiva::BinaryLiteralNode.new(bytes_value)
+ assert_equal(@value, node.value.to_s)
+ end
+ end
+
+ sub_test_case("instance methods") do
+ def setup
+ super
+ @node = Gandiva::BinaryLiteralNode.new(@value)
+ end
+
+ def test_return_type
+ assert_equal(Arrow::BinaryDataType.new, @node.return_type)
+ end
+ end
+end
diff --git a/src/arrow/c_glib/test/gandiva/test-boolean-literal-node.rb b/src/arrow/c_glib/test/gandiva/test-boolean-literal-node.rb
new file mode 100644
index 000000000..6e18a7621
--- /dev/null
+++ b/src/arrow/c_glib/test/gandiva/test-boolean-literal-node.rb
@@ -0,0 +1,32 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+class TestGandivaBooleanLiteralNode < Test::Unit::TestCase
+ def setup
+ omit("Gandiva is required") unless defined?(::Gandiva)
+ @value = true
+ @node = Gandiva::BooleanLiteralNode.new(@value)
+ end
+
+ def test_value
+ assert_equal(@value, @node.value?)
+ end
+
+ def test_return_type
+ assert_equal(Arrow::BooleanDataType.new, @node.return_type)
+ end
+end
diff --git a/src/arrow/c_glib/test/gandiva/test-boolean-node.rb b/src/arrow/c_glib/test/gandiva/test-boolean-node.rb
new file mode 100644
index 000000000..a14685e4e
--- /dev/null
+++ b/src/arrow/c_glib/test/gandiva/test-boolean-node.rb
@@ -0,0 +1,38 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+class TestGandivaBooleanNode < Test::Unit::TestCase
+ def setup
+ omit("Gandiva is required") unless defined?(::Gandiva)
+ field1 = Arrow::Field.new("field1", Arrow::Int32DataType.new)
+ field2 = Arrow::Field.new("field2", Arrow::Int32DataType.new)
+ @field1_node = Gandiva::FieldNode.new(field1)
+ @field2_node = Gandiva::FieldNode.new(field2)
+ end
+
+ def test_and
+ and_node = Gandiva::AndNode.new([@field1_node, @field2_node])
+ assert_equal([@field1_node, @field2_node],
+ and_node.children)
+ end
+
+ def test_or
+ or_node = Gandiva::OrNode.new([@field1_node, @field2_node])
+ assert_equal([@field1_node, @field2_node],
+ or_node.children)
+ end
+end
diff --git a/src/arrow/c_glib/test/gandiva/test-condition.rb b/src/arrow/c_glib/test/gandiva/test-condition.rb
new file mode 100644
index 000000000..51fb9f1b1
--- /dev/null
+++ b/src/arrow/c_glib/test/gandiva/test-condition.rb
@@ -0,0 +1,35 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+class TestGandivaCondition < Test::Unit::TestCase
+ def setup
+ omit("Gandiva is required") unless defined?(::Gandiva)
+ field1 = Arrow::Field.new("field1", Arrow::Int32DataType.new)
+ field2 = Arrow::Field.new("field2", Arrow::Int32DataType.new)
+ field1_node = Gandiva::FieldNode.new(field1)
+ field2_node = Gandiva::FieldNode.new(field2)
+ function_node = Gandiva::FunctionNode.new("equal",
+ [field1_node, field2_node],
+ Arrow::BooleanDataType.new)
+ @condition = Gandiva::Condition.new(function_node)
+ end
+
+ def test_to_s
+ assert_equal("bool equal((int32) field1, (int32) field2)",
+ @condition.to_s)
+ end
+end
diff --git a/src/arrow/c_glib/test/gandiva/test-double-literal-node.rb b/src/arrow/c_glib/test/gandiva/test-double-literal-node.rb
new file mode 100644
index 000000000..27cc3aea2
--- /dev/null
+++ b/src/arrow/c_glib/test/gandiva/test-double-literal-node.rb
@@ -0,0 +1,32 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+class TestGandivaDoubleLiteralNode < Test::Unit::TestCase
+ def setup
+ omit("Gandiva is required") unless defined?(::Gandiva)
+ @value = 1.5
+ @node = Gandiva::DoubleLiteralNode.new(@value)
+ end
+
+ def test_value
+ assert_equal(@value, @node.value)
+ end
+
+ def test_return_type
+ assert_equal(Arrow::DoubleDataType.new, @node.return_type)
+ end
+end
diff --git a/src/arrow/c_glib/test/gandiva/test-expression.rb b/src/arrow/c_glib/test/gandiva/test-expression.rb
new file mode 100644
index 000000000..2e27d6e67
--- /dev/null
+++ b/src/arrow/c_glib/test/gandiva/test-expression.rb
@@ -0,0 +1,46 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+class TestGandivaExpression < Test::Unit::TestCase
+ def setup
+ omit("Gandiva is required") unless defined?(::Gandiva)
+ augend = Arrow::Field.new("augend", Arrow::Int32DataType.new)
+ addend = Arrow::Field.new("addend", Arrow::Int32DataType.new)
+ augend_node = Gandiva::FieldNode.new(augend)
+ addend_node = Gandiva::FieldNode.new(addend)
+ @function_node = Gandiva::FunctionNode.new("add",
+ [augend_node, addend_node],
+ Arrow::Int32DataType.new)
+ @sum = Arrow::Field.new("sum", Arrow::Int32DataType.new)
+ @expression = Gandiva::Expression.new(@function_node, @sum)
+ end
+
+ def test_readers
+ assert_equal([
+ @function_node,
+ @sum
+ ],
+ [
+ @expression.root_node,
+ @expression.result_field
+ ])
+ end
+
+ def test_to_s
+ assert_equal("int32 add((int32) augend, (int32) addend)", @expression.to_s)
+ end
+end
diff --git a/src/arrow/c_glib/test/gandiva/test-field-node.rb b/src/arrow/c_glib/test/gandiva/test-field-node.rb
new file mode 100644
index 000000000..905088128
--- /dev/null
+++ b/src/arrow/c_glib/test/gandiva/test-field-node.rb
@@ -0,0 +1,37 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+class TestGandivaFieldNode < Test::Unit::TestCase
+ def setup
+ omit("Gandiva is required") unless defined?(::Gandiva)
+ @field = Arrow::Field.new("valid", Arrow::BooleanDataType.new)
+ @node = Gandiva::FieldNode.new(@field)
+ end
+
+ def test_field
+ assert_equal(@field, @node.field)
+ end
+
+ def test_return_type
+ assert_equal(@field.data_type, @node.return_type)
+ end
+
+ def test_to_s
+ assert_equal("(bool) valid",
+ @node.to_s)
+ end
+end
diff --git a/src/arrow/c_glib/test/gandiva/test-filter.rb b/src/arrow/c_glib/test/gandiva/test-filter.rb
new file mode 100644
index 000000000..3da777431
--- /dev/null
+++ b/src/arrow/c_glib/test/gandiva/test-filter.rb
@@ -0,0 +1,51 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+class TestGandivaFilter < Test::Unit::TestCase
+ include Helper::Buildable
+
+ def setup
+ omit("Gandiva is required") unless defined?(::Gandiva)
+
+ field1 = Arrow::Field.new("field1", Arrow::Int32DataType.new)
+ field2 = Arrow::Field.new("field2", Arrow::Int32DataType.new)
+ schema = Arrow::Schema.new([field1, field2])
+ field_node1 = Gandiva::FieldNode.new(field1)
+ field_node2 = Gandiva::FieldNode.new(field2)
+ equal_function_node =
+ Gandiva::FunctionNode.new("equal",
+ [field_node1, field_node2],
+ Arrow::BooleanDataType.new)
+ condition = Gandiva::Condition.new(equal_function_node)
+ @filter = Gandiva::Filter.new(schema, condition)
+
+ input_arrays = [
+ build_int32_array([1, 2, 3, 4]),
+ build_int32_array([11, 2, 15, 4]),
+ ]
+ @record_batch = Arrow::RecordBatch.new(schema,
+ input_arrays[0].length,
+ input_arrays)
+ end
+
+ def test_evaluate
+ selection_vector = Gandiva::UInt16SelectionVector.new(@record_batch.n_rows)
+ @filter.evaluate(@record_batch, selection_vector)
+ assert_equal(build_uint16_array([1, 3]),
+ selection_vector.to_array)
+ end
+end
diff --git a/src/arrow/c_glib/test/gandiva/test-float-literal-node.rb b/src/arrow/c_glib/test/gandiva/test-float-literal-node.rb
new file mode 100644
index 000000000..4a49eb374
--- /dev/null
+++ b/src/arrow/c_glib/test/gandiva/test-float-literal-node.rb
@@ -0,0 +1,32 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+class TestGandivaFloatLiteralNode < Test::Unit::TestCase
+ def setup
+ omit("Gandiva is required") unless defined?(::Gandiva)
+ @value = 1.5
+ @node = Gandiva::FloatLiteralNode.new(@value)
+ end
+
+ def test_value
+ assert_equal(@value, @node.value)
+ end
+
+ def test_return_type
+ assert_equal(Arrow::FloatDataType.new, @node.return_type)
+ end
+end
diff --git a/src/arrow/c_glib/test/gandiva/test-function-node.rb b/src/arrow/c_glib/test/gandiva/test-function-node.rb
new file mode 100644
index 000000000..cb4fe0a65
--- /dev/null
+++ b/src/arrow/c_glib/test/gandiva/test-function-node.rb
@@ -0,0 +1,43 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+class TestGandivaFunctionNode < Test::Unit::TestCase
+ def setup
+ omit("Gandiva is required") unless defined?(::Gandiva)
+ end
+
+ def test_readers
+ field1 = Arrow::Field.new("field1", Arrow::Int32DataType.new)
+ field2 = Arrow::Field.new("field2", Arrow::Int32DataType.new)
+ field1_node = Gandiva::FieldNode.new(field1)
+ field2_node = Gandiva::FieldNode.new(field2)
+ return_type = Arrow::Int64DataType.new
+ function_node = Gandiva::FunctionNode.new("add",
+ [field1_node, field2_node],
+ return_type)
+ assert_equal([
+ "add",
+ [field1_node, field2_node],
+ return_type,
+ ],
+ [
+ function_node.name,
+ function_node.parameters,
+ function_node.return_type,
+ ])
+ end
+end
diff --git a/src/arrow/c_glib/test/gandiva/test-function-registry.rb b/src/arrow/c_glib/test/gandiva/test-function-registry.rb
new file mode 100644
index 000000000..25bac6673
--- /dev/null
+++ b/src/arrow/c_glib/test/gandiva/test-function-registry.rb
@@ -0,0 +1,45 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+class TestGandivaFunctionRegistry < Test::Unit::TestCase
+ include Helper::DataType
+
+ def setup
+ omit("Gandiva is required") unless defined?(::Gandiva)
+ @registry = Gandiva::FunctionRegistry.new
+ end
+
+ sub_test_case("lookup") do
+ def test_found
+ native_function = @registry.native_functions[0]
+ assert_equal(native_function,
+ @registry.lookup(native_function.signatures[0]))
+ end
+
+ def test_not_found
+ signature = Gandiva::FunctionSignature.new("nonexistent",
+ [],
+ boolean_data_type)
+ assert_nil(@registry.lookup(signature))
+ end
+ end
+
+ def test_native_functions
+ assert_equal([Gandiva::NativeFunction],
+ @registry.native_functions.collect(&:class).uniq)
+ end
+end
diff --git a/src/arrow/c_glib/test/gandiva/test-function-signature.rb b/src/arrow/c_glib/test/gandiva/test-function-signature.rb
new file mode 100644
index 000000000..ada3bbc8b
--- /dev/null
+++ b/src/arrow/c_glib/test/gandiva/test-function-signature.rb
@@ -0,0 +1,101 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+class TestGandivaFunctionSignature < Test::Unit::TestCase
+ include Helper::DataType
+
+ def setup
+ omit("Gandiva is required") unless defined?(::Gandiva)
+ parameter_types = [string_data_type, string_data_type, int32_data_type]
+ @to_date = Gandiva::FunctionSignature.new("to_date",
+ parameter_types,
+ date64_data_type)
+ end
+
+ def test_new
+ signature = Gandiva::FunctionSignature.new("add",
+ [
+ int32_data_type,
+ int32_data_type,
+ ],
+ int32_data_type)
+ assert_equal("int32 add(int32, int32)",
+ signature.to_s)
+ end
+
+ sub_test_case("equal") do
+ def test_true
+ add_int32_1 = Gandiva::FunctionSignature.new("add",
+ [
+ int32_data_type,
+ int32_data_type,
+ ],
+ int32_data_type)
+ add_int32_2 = Gandiva::FunctionSignature.new("add",
+ [
+ int32_data_type,
+ int32_data_type,
+ ],
+ int32_data_type)
+ assert do
+ add_int32_1 == add_int32_2
+ end
+ end
+
+ def test_false
+ add_int32 = Gandiva::FunctionSignature.new("add",
+ [
+ int32_data_type,
+ int32_data_type,
+ ],
+ int32_data_type)
+ add_int16 = Gandiva::FunctionSignature.new("add",
+ [
+ int16_data_type,
+ int16_data_type,
+ ],
+ int16_data_type)
+ assert do
+ add_int32 != add_int16
+ end
+ end
+ end
+
+ def test_to_string
+ assert_equal("date64[ms] to_date(string, string, int32)",
+ @to_date.to_s)
+ end
+
+ def test_get_return_type
+ assert_equal(date64_data_type,
+ @to_date.return_type)
+ end
+
+ def test_get_base_name
+ assert_equal("to_date",
+ @to_date.base_name)
+ end
+
+ def test_get_param_types
+ assert_equal([
+ string_data_type,
+ string_data_type,
+ int32_data_type,
+ ],
+ @to_date.param_types)
+ end
+end
diff --git a/src/arrow/c_glib/test/gandiva/test-if-node.rb b/src/arrow/c_glib/test/gandiva/test-if-node.rb
new file mode 100644
index 000000000..b00359590
--- /dev/null
+++ b/src/arrow/c_glib/test/gandiva/test-if-node.rb
@@ -0,0 +1,49 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+class TestGandivaIfNode < Test::Unit::TestCase
+ def setup
+ omit("Gandiva is required") unless defined?(::Gandiva)
+ field1 = Arrow::Field.new("field1", Arrow::Int32DataType.new)
+ field2 = Arrow::Field.new("field2", Arrow::Int32DataType.new)
+ @then_node = Gandiva::FieldNode.new(field1)
+ @else_node = Gandiva::FieldNode.new(field2)
+ @return_type = Arrow::Int32DataType.new
+ @condition_node = Gandiva::FunctionNode.new("greater_than",
+ [@then_node, @else_node],
+ @return_type)
+ @if_node = Gandiva::IfNode.new(@condition_node,
+ @then_node,
+ @else_node,
+ @return_type)
+ end
+
+ def test_readers
+ assert_equal([
+ @condition_node,
+ @then_node,
+ @else_node,
+ @return_type
+ ],
+ [
+ @if_node.condition_node,
+ @if_node.then_node,
+ @if_node.else_node,
+ @if_node.return_type
+ ])
+ end
+end
diff --git a/src/arrow/c_glib/test/gandiva/test-int16-literal-node.rb b/src/arrow/c_glib/test/gandiva/test-int16-literal-node.rb
new file mode 100644
index 000000000..f8e6b2684
--- /dev/null
+++ b/src/arrow/c_glib/test/gandiva/test-int16-literal-node.rb
@@ -0,0 +1,32 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+class TestGandivaInt16LiteralNode < Test::Unit::TestCase
+ def setup
+ omit("Gandiva is required") unless defined?(::Gandiva)
+ @value = -(2 ** 15)
+ @node = Gandiva::Int16LiteralNode.new(@value)
+ end
+
+ def test_value
+ assert_equal(@value, @node.value)
+ end
+
+ def test_return_type
+ assert_equal(Arrow::Int16DataType.new, @node.return_type)
+ end
+end
diff --git a/src/arrow/c_glib/test/gandiva/test-int32-literal-node.rb b/src/arrow/c_glib/test/gandiva/test-int32-literal-node.rb
new file mode 100644
index 000000000..3d1bf588c
--- /dev/null
+++ b/src/arrow/c_glib/test/gandiva/test-int32-literal-node.rb
@@ -0,0 +1,32 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+class TestGandivaInt32LiteralNode < Test::Unit::TestCase
+ def setup
+ omit("Gandiva is required") unless defined?(::Gandiva)
+ @value = -(2 ** 31)
+ @node = Gandiva::Int32LiteralNode.new(@value)
+ end
+
+ def test_value
+ assert_equal(@value, @node.value)
+ end
+
+ def test_return_type
+ assert_equal(Arrow::Int32DataType.new, @node.return_type)
+ end
+end
diff --git a/src/arrow/c_glib/test/gandiva/test-int64-literal-node.rb b/src/arrow/c_glib/test/gandiva/test-int64-literal-node.rb
new file mode 100644
index 000000000..b2ca3bf63
--- /dev/null
+++ b/src/arrow/c_glib/test/gandiva/test-int64-literal-node.rb
@@ -0,0 +1,32 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+class TestGandivaInt64LiteralNode < Test::Unit::TestCase
+ def setup
+ omit("Gandiva is required") unless defined?(::Gandiva)
+ @value = -(2 ** 63)
+ @node = Gandiva::Int64LiteralNode.new(@value)
+ end
+
+ def test_value
+ assert_equal(@value, @node.value)
+ end
+
+ def test_return_type
+ assert_equal(Arrow::Int64DataType.new, @node.return_type)
+ end
+end
diff --git a/src/arrow/c_glib/test/gandiva/test-int8-literal-node.rb b/src/arrow/c_glib/test/gandiva/test-int8-literal-node.rb
new file mode 100644
index 000000000..8d917bd1b
--- /dev/null
+++ b/src/arrow/c_glib/test/gandiva/test-int8-literal-node.rb
@@ -0,0 +1,32 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+class TestGandivaInt8LiteralNode < Test::Unit::TestCase
+ def setup
+ omit("Gandiva is required") unless defined?(::Gandiva)
+ @value = -(2 ** 7)
+ @node = Gandiva::Int8LiteralNode.new(@value)
+ end
+
+ def test_value
+ assert_equal(@value, @node.value)
+ end
+
+ def test_return_type
+ assert_equal(Arrow::Int8DataType.new, @node.return_type)
+ end
+end
diff --git a/src/arrow/c_glib/test/gandiva/test-native-function.rb b/src/arrow/c_glib/test/gandiva/test-native-function.rb
new file mode 100644
index 000000000..7888f96b6
--- /dev/null
+++ b/src/arrow/c_glib/test/gandiva/test-native-function.rb
@@ -0,0 +1,132 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+class TestGandivaNativeFunction < Test::Unit::TestCase
+ include Helper::DataType
+
+ def setup
+ omit("Gandiva is required") unless defined?(::Gandiva)
+ @registry = Gandiva::FunctionRegistry.new
+ @not = lookup("not", [boolean_data_type], boolean_data_type)
+ @isnull = lookup("isnull", [int8_data_type], boolean_data_type)
+ end
+
+ def lookup(name, param_types, return_type)
+ signature = Gandiva::FunctionSignature.new(name,
+ param_types,
+ return_type)
+ @registry.lookup(signature)
+ end
+
+ def test_signatures
+ assert_equal([Gandiva::FunctionSignature],
+ @not.signatures.collect(&:class).uniq)
+ end
+
+ sub_test_case("equal") do
+ def test_true
+ assert do
+ @not == @registry.lookup(@not.signatures[0])
+ end
+ end
+
+ def test_false
+ assert do
+ @not != @isnull
+ end
+ end
+ end
+
+ def test_to_string
+ modulo = lookup("modulo",
+ [int64_data_type, int64_data_type],
+ int64_data_type)
+ assert_equal(modulo.signatures.collect(&:to_s).join(", "),
+ modulo.to_s)
+ end
+
+ sub_test_case("get_result_nullbale_type") do
+ def test_if_null
+ assert_equal(Gandiva::ResultNullableType::IF_NULL,
+ @not.result_nullable_type)
+ end
+
+ def test_never
+ assert_equal(Gandiva::ResultNullableType::NEVER,
+ @isnull.result_nullable_type)
+ end
+
+ def test_internal
+ to_date = lookup("to_date",
+ [string_data_type, string_data_type, int32_data_type],
+ date64_data_type)
+ assert_equal(Gandiva::ResultNullableType::INTERNAL,
+ to_date.result_nullable_type)
+ end
+ end
+
+ sub_test_case("need_context") do
+ def test_need
+ assert do
+ not @not.need_context
+ end
+ end
+
+ def test_not_need
+ upper = lookup("upper",
+ [string_data_type],
+ string_data_type)
+ assert do
+ upper.need_context
+ end
+ end
+ end
+
+ sub_test_case("need_function_holder") do
+ def test_need
+ like = lookup("like",
+ [string_data_type, string_data_type],
+ boolean_data_type)
+ assert do
+ like.need_function_holder
+ end
+ end
+
+ def test_not_need
+ assert do
+ not @not.need_function_holder
+ end
+ end
+ end
+
+ sub_test_case("can_return_errors") do
+ def test_can
+ divide = lookup("divide",
+ [int8_data_type, int8_data_type],
+ int8_data_type)
+ assert do
+ divide.can_return_errors?
+ end
+ end
+
+ def test_not_can
+ assert do
+ not @not.can_return_errors?
+ end
+ end
+ end
+end
diff --git a/src/arrow/c_glib/test/gandiva/test-null-literal-node.rb b/src/arrow/c_glib/test/gandiva/test-null-literal-node.rb
new file mode 100644
index 000000000..ae14f3c15
--- /dev/null
+++ b/src/arrow/c_glib/test/gandiva/test-null-literal-node.rb
@@ -0,0 +1,38 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+class TestGandivaNullLiteralNode < Test::Unit::TestCase
+ def setup
+ omit("Gandiva is required") unless defined?(::Gandiva)
+ end
+
+ def test_invalid_type
+ return_type = Arrow::NullDataType.new
+ message =
+ "[gandiva][null-literal-node][new] " +
+ "failed to create: <#{return_type}>"
+ assert_raise(Arrow::Error::Invalid.new(message)) do
+ Gandiva::NullLiteralNode.new(return_type)
+ end
+ end
+
+ def test_return_type
+ return_type = Arrow::BooleanDataType.new
+ literal_node = Gandiva::NullLiteralNode.new(return_type)
+ assert_equal(return_type, literal_node.return_type)
+ end
+end
diff --git a/src/arrow/c_glib/test/gandiva/test-projector.rb b/src/arrow/c_glib/test/gandiva/test-projector.rb
new file mode 100644
index 000000000..308e1c3a5
--- /dev/null
+++ b/src/arrow/c_glib/test/gandiva/test-projector.rb
@@ -0,0 +1,63 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+class TestGandivaProjector < Test::Unit::TestCase
+ include Helper::Buildable
+
+ def setup
+ omit("Gandiva is required") unless defined?(::Gandiva)
+
+ field1 = Arrow::Field.new("field1", Arrow::Int32DataType.new)
+ field2 = Arrow::Field.new("field2", Arrow::Int32DataType.new)
+ @schema = Arrow::Schema.new([field1, field2])
+ @field_node1 = Gandiva::FieldNode.new(field1)
+ @field_node2 = Gandiva::FieldNode.new(field2)
+ add_function_node =
+ Gandiva::FunctionNode.new("add",
+ [@field_node1, @field_node2],
+ Arrow::Int32DataType.new)
+ subtract_function_node =
+ Gandiva::FunctionNode.new("subtract",
+ [@field_node1, @field_node2],
+ Arrow::Int32DataType.new)
+ add_result = Arrow::Field.new("add_result", Arrow::Int32DataType.new)
+ add_expression = Gandiva::Expression.new(add_function_node, add_result)
+ subtract_result = Arrow::Field.new("subtract_result",
+ Arrow::Int32DataType.new)
+ subtract_expression = Gandiva::Expression.new(subtract_function_node,
+ subtract_result)
+ @projector = Gandiva::Projector.new(@schema,
+ [add_expression, subtract_expression])
+
+ input_arrays = [
+ build_int32_array([1, 2, 3, 4]),
+ build_int32_array([11, 13, 15, 17]),
+ ]
+ @record_batch = Arrow::RecordBatch.new(@schema,
+ input_arrays[0].length,
+ input_arrays)
+ end
+
+ def test_evaluate
+ outputs = @projector.evaluate(@record_batch)
+ assert_equal([
+ [12, 15, 18, 21],
+ [-10, -11, -12, -13],
+ ],
+ outputs.collect(&:values))
+ end
+end
diff --git a/src/arrow/c_glib/test/gandiva/test-selectable-projector.rb b/src/arrow/c_glib/test/gandiva/test-selectable-projector.rb
new file mode 100644
index 000000000..47b0059a2
--- /dev/null
+++ b/src/arrow/c_glib/test/gandiva/test-selectable-projector.rb
@@ -0,0 +1,74 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+class TestGandivaSelectableProjector < Test::Unit::TestCase
+ include Helper::Buildable
+
+ def setup
+ omit("Gandiva is required") unless defined?(::Gandiva)
+
+ field1 = Arrow::Field.new("field1", Arrow::Int32DataType.new)
+ field2 = Arrow::Field.new("field2", Arrow::Int32DataType.new)
+ @schema = Arrow::Schema.new([field1, field2])
+
+ input_arrays = [
+ build_int32_array([1, 2, 3, 4]),
+ build_int32_array([11, 13, 15, 17]),
+ ]
+ @record_batch = Arrow::RecordBatch.new(@schema,
+ input_arrays[0].length,
+ input_arrays)
+
+ @field_node1 = Gandiva::FieldNode.new(field1)
+ @field_node2 = Gandiva::FieldNode.new(field2)
+ add_function_node =
+ Gandiva::FunctionNode.new("add",
+ [@field_node1, @field_node2],
+ Arrow::Int32DataType.new)
+ subtract_function_node =
+ Gandiva::FunctionNode.new("subtract",
+ [@field_node1, @field_node2],
+ Arrow::Int32DataType.new)
+ add_result = Arrow::Field.new("add_result", Arrow::Int32DataType.new)
+ add_expression = Gandiva::Expression.new(add_function_node, add_result)
+ subtract_result = Arrow::Field.new("subtract_result",
+ Arrow::Int32DataType.new)
+ subtract_expression = Gandiva::Expression.new(subtract_function_node,
+ subtract_result)
+ @selection_vector = Gandiva::UInt16SelectionVector.new(@record_batch.n_rows)
+ @projector =
+ Gandiva::SelectableProjector.new(@schema,
+ [add_expression, subtract_expression],
+ @selection_vector.mode)
+ end
+
+ def test_evaluate
+ two_node = Gandiva::Int32LiteralNode.new(2)
+ condition_node = Gandiva::FunctionNode.new("greater_than",
+ [@field_node1, two_node],
+ Arrow::BooleanDataType.new)
+ condition = Gandiva::Condition.new(condition_node)
+ filter = Gandiva::Filter.new(@schema, condition)
+ filter.evaluate(@record_batch, @selection_vector)
+ outputs = @projector.evaluate(@record_batch, @selection_vector)
+ assert_equal([
+ [18, 21],
+ [-12, -13],
+ ],
+ outputs.collect(&:values))
+ end
+end
diff --git a/src/arrow/c_glib/test/gandiva/test-selection-vector.rb b/src/arrow/c_glib/test/gandiva/test-selection-vector.rb
new file mode 100644
index 000000000..ca5042c28
--- /dev/null
+++ b/src/arrow/c_glib/test/gandiva/test-selection-vector.rb
@@ -0,0 +1,42 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+class TestGandivaSelectionVector < Test::Unit::TestCase
+ include Helper::Buildable
+
+ def setup
+ omit("Gandiva is required") unless defined?(::Gandiva)
+ end
+
+ def test_uint16
+ selection_vector = Gandiva::UInt16SelectionVector.new(10)
+ assert_equal(build_uint16_array([]),
+ selection_vector.to_array)
+ end
+
+ def test_uint32
+ selection_vector = Gandiva::UInt32SelectionVector.new(10)
+ assert_equal(build_uint32_array([]),
+ selection_vector.to_array)
+ end
+
+ def test_uint64
+ selection_vector = Gandiva::UInt64SelectionVector.new(10)
+ assert_equal(build_uint64_array([]),
+ selection_vector.to_array)
+ end
+end
diff --git a/src/arrow/c_glib/test/gandiva/test-string-literal-node.rb b/src/arrow/c_glib/test/gandiva/test-string-literal-node.rb
new file mode 100644
index 000000000..8a397ab4d
--- /dev/null
+++ b/src/arrow/c_glib/test/gandiva/test-string-literal-node.rb
@@ -0,0 +1,32 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+class TestGandivaStringLiteralNode < Test::Unit::TestCase
+ def setup
+ omit("Gandiva is required") unless defined?(::Gandiva)
+ @value = "Hello"
+ @node = Gandiva::StringLiteralNode.new(@value)
+ end
+
+ def test_value
+ assert_equal(@value, @node.value)
+ end
+
+ def test_return_type
+ assert_equal(Arrow::StringDataType.new, @node.return_type)
+ end
+end
diff --git a/src/arrow/c_glib/test/gandiva/test-uint16-literal-node.rb b/src/arrow/c_glib/test/gandiva/test-uint16-literal-node.rb
new file mode 100644
index 000000000..971da3888
--- /dev/null
+++ b/src/arrow/c_glib/test/gandiva/test-uint16-literal-node.rb
@@ -0,0 +1,32 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+class TestGandivaUInt16LiteralNode < Test::Unit::TestCase
+ def setup
+ omit("Gandiva is required") unless defined?(::Gandiva)
+ @value = 2 ** 16 - 1
+ @node = Gandiva::UInt16LiteralNode.new(@value)
+ end
+
+ def test_value
+ assert_equal(@value, @node.value)
+ end
+
+ def test_return_type
+ assert_equal(Arrow::UInt16DataType.new, @node.return_type)
+ end
+end
diff --git a/src/arrow/c_glib/test/gandiva/test-uint32-literal-node.rb b/src/arrow/c_glib/test/gandiva/test-uint32-literal-node.rb
new file mode 100644
index 000000000..8fcab7fef
--- /dev/null
+++ b/src/arrow/c_glib/test/gandiva/test-uint32-literal-node.rb
@@ -0,0 +1,32 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+class TestGandivaUInt32LiteralNode < Test::Unit::TestCase
+ def setup
+ omit("Gandiva is required") unless defined?(::Gandiva)
+ @value = 2 ** 32 - 1
+ @node = Gandiva::UInt32LiteralNode.new(@value)
+ end
+
+ def test_value
+ assert_equal(@value, @node.value)
+ end
+
+ def test_return_type
+ assert_equal(Arrow::UInt32DataType.new, @node.return_type)
+ end
+end
diff --git a/src/arrow/c_glib/test/gandiva/test-uint64-literal-node.rb b/src/arrow/c_glib/test/gandiva/test-uint64-literal-node.rb
new file mode 100644
index 000000000..d5afddcd7
--- /dev/null
+++ b/src/arrow/c_glib/test/gandiva/test-uint64-literal-node.rb
@@ -0,0 +1,32 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+class TestGandivaUInt64LiteralNode < Test::Unit::TestCase
+ def setup
+ omit("Gandiva is required") unless defined?(::Gandiva)
+ @value = 3
+ @node = Gandiva::UInt64LiteralNode.new(@value)
+ end
+
+ def test_value
+ assert_equal(@value, @node.value)
+ end
+
+ def test_return_type
+ assert_equal(Arrow::UInt64DataType.new, @node.return_type)
+ end
+end
diff --git a/src/arrow/c_glib/test/gandiva/test-uint8-literal-node.rb b/src/arrow/c_glib/test/gandiva/test-uint8-literal-node.rb
new file mode 100644
index 000000000..8ce91d599
--- /dev/null
+++ b/src/arrow/c_glib/test/gandiva/test-uint8-literal-node.rb
@@ -0,0 +1,32 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+class TestGandivaUInt8LiteralNode < Test::Unit::TestCase
+ def setup
+ omit("Gandiva is required") unless defined?(::Gandiva)
+ @value = 2 ** 8 - 1
+ @node = Gandiva::UInt8LiteralNode.new(@value)
+ end
+
+ def test_value
+ assert_equal(@value, @node.value)
+ end
+
+ def test_return_type
+ assert_equal(Arrow::UInt8DataType.new, @node.return_type)
+ end
+end