kou commented on code in PR #40403:
URL: https://github.com/apache/arrow/pull/40403#discussion_r1517160018
##########
c_glib/arrow-glib/compute.cpp:
##########
@@ -240,6 +241,16 @@ G_BEGIN_DECLS
* #GArrowRunEndEncodeOptions is a class to customize the
* `run_end_encode` function.
*
+ * #GArrowStrptimeOptions is a class to customize the `strptime` function.
+ *
+ * #GArrowStrftimeOptions is a class to customize the `strftime` function.
+ *
+ * #GArrowSplitPatternOptions is a class to customize the `split_pattern` and
+ * `split_pattern_regex` functions.
+ *
+ * #GArrowStructFieldOptions is a class to customize the `struct_field`
+ * function.
Review Comment:
```suggestion
* function.
```
##########
c_glib/test/test-split-pattern-options.rb:
##########
@@ -0,0 +1,56 @@
+# 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 TestSplitPatternOptions < Test::Unit::TestCase
+ include Helper::Buildable
+
+ def setup
+ @options = Arrow::SplitPatternOptions.new
+ end
+
+ def test_pattern_property
+ assert_equal("", @options.pattern)
+ @options.pattern = "foo"
+ assert_equal("foo", @options.pattern)
+ end
+
+ def test_max_splits_property
+ assert_equal(-1, @options.max_splits)
+ @options.max_splits = 1
+ assert_equal(1, @options.max_splits)
+ end
+
+ def test_reverse_property
+ assert do
+ [email protected]?
+ end
+ @options.reverse = true
+ assert do
+ @options.reverse?
+ end
+ end
+
+ def test_split_pattern_regex_function
+ args = [
+ Arrow::ArrayDatum.new(build_string_array(["hello world"])),
+ ]
+ @options.pattern = "[lo]+"
+ split_pattern_regex_function = Arrow::Function.find("split_pattern_regex")
+ assert_equal(build_list_array(Arrow::StringDataType.new, [["he", " w",
"r", "d"]]),
+ split_pattern_regex_function.execute(args, @options).value)
Review Comment:
```suggestion
split_pattern_regex_function.execute(args, @options).value)
```
##########
c_glib/test/test-struct-field-options.rb:
##########
@@ -0,0 +1,75 @@
+# 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 TestStructFieldOptions < Test::Unit::TestCase
+ include Helper::Buildable
+
+ def setup
+ @options = Arrow::StructFieldOptions.new
+ end
+
+ def test_default
+ assert_equal("", @options.field_ref)
+ end
+
+ def test_set_string
+ @options.field_ref = "foo"
+ assert_equal("foo", @options.field_ref)
+ end
+
+ def test_sset_ymbol
Review Comment:
```suggestion
def test_set_symbol
```
##########
c_glib/test/test-struct-field-options.rb:
##########
@@ -0,0 +1,75 @@
+# 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 TestStructFieldOptions < Test::Unit::TestCase
+ include Helper::Buildable
+
+ def setup
+ @options = Arrow::StructFieldOptions.new
+ end
+
+ def test_default
+ assert_equal("", @options.field_ref)
+ end
+
+ def test_set_string
+ @options.field_ref = "foo"
+ assert_equal("foo", @options.field_ref)
+ end
+
+ def test_sset_ymbol
+ @options.field_ref = :foo
+ assert_equal("foo", @options.field_ref)
+ end
+
+ def test_set_dot_path
+ @options.field_ref = ".foo.bar"
+ assert_equal(".foo.bar", @options.field_ref)
+ end
+
+ def test_set_invalid
+ message = "[struct-field-options][set-field-ref]: Invalid: Dot path
'[foo]' contained an unterminated index"
+ assert_raise(Arrow::Error::Invalid.new(message)) do
+ @options.field_ref = "[foo]"
+ end
+ end
+
+ def test_struct_field_function
+ fields = [
+ Arrow::Field.new("score", Arrow::Int8DataType.new),
+ Arrow::Field.new("enabled", Arrow::BooleanDataType.new),
+ ]
+ structs = [
+ {
+ "score" => -29,
+ "enabled" => true,
+ },
+ {
+ "score" => 2,
+ "enabled" => false,
+ },
+ nil,
+ ]
+ args = [
+ Arrow::ArrayDatum.new(build_struct_array(fields, structs)),
+ ]
+ @options.field_ref = "score"
+ struct_field_function = Arrow::Function.find("struct_field")
+ assert_equal(build_int8_array([-29, 2, nil]),
+ struct_field_function.execute(args, @options).value)
Review Comment:
```suggestion
struct_field_function.execute(args, @options).value)
```
##########
c_glib/arrow-glib/compute.cpp:
##########
@@ -240,6 +241,16 @@ G_BEGIN_DECLS
* #GArrowRunEndEncodeOptions is a class to customize the
* `run_end_encode` function.
*
+ * #GArrowStrptimeOptions is a class to customize the `strptime` function.
+ *
+ * #GArrowStrftimeOptions is a class to customize the `strftime` function.
+ *
+ * #GArrowSplitPatternOptions is a class to customize the `split_pattern` and
+ * `split_pattern_regex` functions.
Review Comment:
```suggestion
* `split_pattern_regex` functions.
```
##########
c_glib/test/test-strptime-options.rb:
##########
@@ -0,0 +1,57 @@
+# 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 TestStrptimeOptions < Test::Unit::TestCase
+ include Helper::Buildable
+
+ def setup
+ @options = Arrow::StrptimeOptions.new
+ end
+
+ def test_format_property
+ assert_equal("", @options.format)
+ @options.format = "%Y-%m-%d"
+ assert_equal("%Y-%m-%d", @options.format)
+ end
+
+ def test_unit_property
+ assert_equal(Arrow::TimeUnit::MICRO, @options.unit)
+ @options.unit = :nano
+ assert_equal(Arrow::TimeUnit::NANO, @options.unit)
+ end
+
+ def test_error_is_null_property
+ assert do
+ [email protected]_is_null?
+ end
+ @options.error_is_null = true
+ assert do
+ @options.error_is_null?
+ end
+ end
+
+ def test_strptime_function
+ args = [
+ Arrow::ArrayDatum.new(build_string_array(["2017-09-09T10:33:10"])),
+ ]
+ @options.format = "%Y-%m-%dT%H:%M:%S"
+ @options.unit = :milli
+ strptime_function = Arrow::Function.find("strptime")
+ assert_equal(build_timestamp_array(:milli, [1504953190000]),
+ strptime_function.execute(args, @options).value)
Review Comment:
```suggestion
strptime_function.execute(args, @options).value)
```
##########
c_glib/arrow-glib/compute.cpp:
##########
@@ -2773,6 +2784,7 @@ garrow_filter_options_get_property(GObject *object,
}
}
+
Review Comment:
```suggestion
```
##########
c_glib/test/test-strftime-options.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 TestStrftimeOptions < Test::Unit::TestCase
+ include Helper::Buildable
+
+ def setup
+ @options = Arrow::StrftimeOptions.new
+ end
+
+ def test_format_property
+ assert_equal("%Y-%m-%dT%H:%M:%S", @options.format)
+ @options.format = "%Y-%m-%d"
+ assert_equal("%Y-%m-%d", @options.format)
+ end
+
+ def test_locale_property
+ assert_equal("C", @options.locale)
+ @options.locale = "sv_SE.UTF-8"
+ assert_equal("sv_SE.UTF-8", @options.locale)
+ end
+
+ def test_strftime_function
+ omit("Missing tzdata on Windows") if Gem.win_platform?
+ args = [
+ Arrow::ArrayDatum.new(build_timestamp_array(:milli, [1504953190854])),
+ ]
+ @options.format = "%Y-%m-%d"
+ strftime_function = Arrow::Function.find("strftime")
+ assert_equal(build_string_array(["2017-09-09"]),
+ strftime_function.execute(args, @options).value)
Review Comment:
```suggestion
strftime_function.execute(args, @options).value)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]