Class: Polars::ScanCastOptions

Inherits:
Object
  • Object
show all
Defined in:
lib/polars/scan_cast_options.rb

Overview

Options for scanning files.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(integer_cast: "forbid", float_cast: "forbid", datetime_cast: "forbid", missing_struct_fields: "raise", extra_struct_fields: "raise", _internal_call: false) ⇒ ScanCastOptions

Note:

This functionality is considered unstable. It may be changed at any point without it being considered a breaking change.

Common configuration for scanning files.

Parameters:

  • integer_cast ('upcast', 'forbid') (defaults to: "forbid")

    Configuration for casting from integer types:

    • upcast: Allow lossless casting to wider integer types.
    • forbid: Raises an error if dtypes do not match.
  • float_cast ('upcast', 'downcast', 'forbid') (defaults to: "forbid")

    Configuration for casting from float types:

    • upcast: Allow casting to higher precision float types.
    • downcast: Allow casting to lower precision float types.
    • forbid: Raises an error if dtypes do not match.
  • datetime_cast ('nanosecond-downcast', 'convert-timezone', 'forbid') (defaults to: "forbid")

    Configuration for casting from datetime types:

    • nanosecond-downcast: Allow nanosecond precision datetime to be downcasted to any lower precision. This has a similar effect to PyArrow's coerce_int96_timestamp_unit.
    • convert-timezone: Allow casting to a different timezone.
    • forbid: Raises an error if dtypes do not match.
  • missing_struct_fields ('insert', 'raise') (defaults to: "raise")

    Configuration for behavior when struct fields defined in the schema are missing from the data:

    • insert: Inserts the missing fields.
    • raise: Raises an error.
  • extra_struct_fields ('ignore', 'raise') (defaults to: "raise")

    Configuration for behavior when extra struct fields outside of the defined schema are encountered in the data:

    • ignore: Silently ignores.
    • raise: Raises an error.


45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/polars/scan_cast_options.rb', line 45

def initialize(
  integer_cast: "forbid",
  float_cast: "forbid",
  datetime_cast: "forbid",
  missing_struct_fields: "raise",
  extra_struct_fields: "raise",
  _internal_call: false
)
  @integer_cast = integer_cast
  @float_cast = float_cast
  @datetime_cast = datetime_cast
  @missing_struct_fields = missing_struct_fields
  @extra_struct_fields = extra_struct_fields
end

Class Method Details

.defaultObject



60
61
62
# File 'lib/polars/scan_cast_options.rb', line 60

def self.default
  new(_internal_call: true)
end