diff --git a/c_glib/test/test-array-datum.rb b/c_glib/test/test-array-datum.rb index 623e5589ce40b..1b2c9f91e2aa2 100644 --- a/c_glib/test/test-array-datum.rb +++ b/c_glib/test/test-array-datum.rb @@ -61,7 +61,7 @@ def test_false end def test_to_string - assert_equal("Array", @datum.to_s) + assert_equal("Array([\n" + " true,\n" + " false\n" + "])", @datum.to_s) end def test_value diff --git a/c_glib/test/test-chunked-array-datum.rb b/c_glib/test/test-chunked-array-datum.rb index 76317315327e8..b82f3eed8a7af 100644 --- a/c_glib/test/test-chunked-array-datum.rb +++ b/c_glib/test/test-chunked-array-datum.rb @@ -49,7 +49,7 @@ def test_false end def test_to_string - assert_equal("ChunkedArray", @datum.to_s) + assert_equal("ChunkedArray([\n" + " [\n" + " true,\n" + " false\n" + " ]\n" + "])", @datum.to_s) end def test_value diff --git a/c_glib/test/test-record-batch-datum.rb b/c_glib/test/test-record-batch-datum.rb index 33eb793ba869a..ec572e0f13023 100644 --- a/c_glib/test/test-record-batch-datum.rb +++ b/c_glib/test/test-record-batch-datum.rb @@ -49,7 +49,7 @@ def test_false end def test_to_string - assert_equal("RecordBatch", @datum.to_s) + assert_equal("RecordBatch(visible: [\n" + " true,\n" + " false\n" + " ]\n" + ")", @datum.to_s) end def test_value diff --git a/c_glib/test/test-scalar-datum.rb b/c_glib/test/test-scalar-datum.rb index 17e5d6b061cc7..32a5331518d8b 100644 --- a/c_glib/test/test-scalar-datum.rb +++ b/c_glib/test/test-scalar-datum.rb @@ -60,7 +60,7 @@ def test_false end def test_to_string - assert_equal("Scalar", @datum.to_s) + assert_equal("Scalar(true)", @datum.to_s) end def test_value diff --git a/c_glib/test/test-table-datum.rb b/c_glib/test/test-table-datum.rb index 7ff3997e88a37..c34ecf6314118 100644 --- a/c_glib/test/test-table-datum.rb +++ b/c_glib/test/test-table-datum.rb @@ -49,7 +49,16 @@ def test_false end def test_to_string - assert_equal("Table", @datum.to_s) + assert_equal("Table(visible: bool\n" + + "----\n" + + "visible:\n" + + " [\n" + + " [\n" + + " true,\n" + + " false\n" + + " ]\n" + + " ]\n" + + ")", @datum.to_s) end def test_value diff --git a/cpp/src/arrow/datum.cc b/cpp/src/arrow/datum.cc index d0b5cf62c61be..2ac230232e1b7 100644 --- a/cpp/src/arrow/datum.cc +++ b/cpp/src/arrow/datum.cc @@ -182,15 +182,15 @@ std::string Datum::ToString() const { case Datum::NONE: return "nullptr"; case Datum::SCALAR: - return "Scalar"; + return "Scalar(" + scalar()->ToString() + ")"; case Datum::ARRAY: - return "Array"; + return "Array(" + make_array()->ToString() + ")"; case Datum::CHUNKED_ARRAY: - return "ChunkedArray"; + return "ChunkedArray(" + chunked_array()->ToString() + ")"; case Datum::RECORD_BATCH: - return "RecordBatch"; + return "RecordBatch(" + record_batch()->ToString() + ")"; case Datum::TABLE: - return "Table"; + return "Table(" + table()->ToString() + ")"; default: DCHECK(false); return ""; diff --git a/cpp/src/arrow/datum.h b/cpp/src/arrow/datum.h index 57ae3731b5ccd..31b2d2274c900 100644 --- a/cpp/src/arrow/datum.h +++ b/cpp/src/arrow/datum.h @@ -301,7 +301,6 @@ struct ARROW_EXPORT Datum { bool operator==(const Datum& other) const { return Equals(other); } bool operator!=(const Datum& other) const { return !Equals(other); } - /// \brief Return a string representation of the kind of datum stored. std::string ToString() const; }; diff --git a/cpp/src/arrow/datum_test.cc b/cpp/src/arrow/datum_test.cc index 14daac6a794fc..909d2577e68fb 100644 --- a/cpp/src/arrow/datum_test.cc +++ b/cpp/src/arrow/datum_test.cc @@ -154,8 +154,8 @@ TEST(Datum, ToString) { Datum v1(arr); Datum v2(std::make_shared(1)); - ASSERT_EQ("Array", v1.ToString()); - ASSERT_EQ("Scalar", v2.ToString()); + ASSERT_EQ("Array([\n 1,\n 2,\n 3,\n 4\n])", v1.ToString()); + ASSERT_EQ("Scalar(1)", v2.ToString()); } TEST(Datum, TotalBufferSize) {