Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-30717: [C#] Add ToString() methods to Arrow classes #36566

Merged
merged 7 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion csharp/src/Apache.Arrow/ChunkedArray.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

using System;
using System.Collections.Generic;
using Apache.Arrow;
using Apache.Arrow.Types;

namespace Apache.Arrow
Expand Down Expand Up @@ -86,6 +85,8 @@ public ChunkedArray Slice(long offset)
return Slice(offset, Length - offset);
}

public override string ToString() => $"{nameof(ChunkedArray)}: Length={Length}, DataType={DataType.Name}";

// TODO: Flatten for Structs
}
}
2 changes: 2 additions & 0 deletions csharp/src/Apache.Arrow/Field.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ public partial class Field

public IReadOnlyDictionary<string, string> Metadata { get; }

public override string ToString() => $"{nameof(Field)}: Name={Name}, Data type={DataType.Name}, IsNullable={IsNullable}, Num metadata={Metadata?.Count}";

public Field(string name, IArrowType dataType, bool nullable,
IEnumerable<KeyValuePair<string, string>> metadata = default)
: this(name, dataType, nullable)
Expand Down
2 changes: 2 additions & 0 deletions csharp/src/Apache.Arrow/RecordBatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,7 @@ public RecordBatch Clone(MemoryAllocator allocator = default)
IEnumerable<IArrowArray> arrays = _arrays.Select(array => ArrowArrayFactory.BuildArray(array.Data.Clone(allocator)));
return new RecordBatch(Schema, arrays, Length);
}

public override string ToString() => $"{nameof(RecordBatch)}: Length={Length}, ColumnCount={ColumnCount}";
voidstar69 marked this conversation as resolved.
Show resolved Hide resolved
}
}
2 changes: 2 additions & 0 deletions csharp/src/Apache.Arrow/Schema.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,5 +114,7 @@ public Schema SetField(int fieldIndex, Field newField)

return new Schema(fields, Metadata);
}

public override string ToString() => $"{nameof(Schema)}: Num fields={_fieldsList.Count}, Num metadata={Metadata?.Count}";
voidstar69 marked this conversation as resolved.
Show resolved Hide resolved
}
}
2 changes: 2 additions & 0 deletions csharp/src/Apache.Arrow/Table.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ public Table SetColumn(int columnIndex, Column column)
return new Table(newSchema, newColumns);
}

public override string ToString() => $"{nameof(Table)}: {ColumnCount} columns by {RowCount} rows";

// TODO: Flatten for Tables with Lists/Structs?
}
}