Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
ScalarValue in datafusion::scalar - Rust
[go: Go Back, main page]

pub enum ScalarValue {
Show 34 variants Null, Boolean(Option<bool>), Float32(Option<f32>), Float64(Option<f64>), Decimal128(Option<i128>, u8i8), Int8(Option<i8>), Int16(Option<i16>), Int32(Option<i32>), Int64(Option<i64>), UInt8(Option<u8>), UInt16(Option<u16>), UInt32(Option<u32>), UInt64(Option<u64>), Utf8(Option<String>), LargeUtf8(Option<String>), Binary(Option<Vec<u8, Global>>), FixedSizeBinary(i32Option<Vec<u8, Global>>), LargeBinary(Option<Vec<u8, Global>>), List(Option<Vec<ScalarValue, Global>>, Box<Field, Global>), Date32(Option<i32>), Date64(Option<i64>), Time32Second(Option<i32>), Time32Millisecond(Option<i32>), Time64Microsecond(Option<i64>), Time64Nanosecond(Option<i64>), TimestampSecond(Option<i64>, Option<String>), TimestampMillisecond(Option<i64>, Option<String>), TimestampMicrosecond(Option<i64>, Option<String>), TimestampNanosecond(Option<i64>, Option<String>), IntervalYearMonth(Option<i32>), IntervalDayTime(Option<i64>), IntervalMonthDayNano(Option<i128>), Struct(Option<Vec<ScalarValue, Global>>, Box<Vec<Field, Global>, Global>), Dictionary(Box<DataType, Global>, Box<ScalarValue, Global>),
}
Expand description

Represents a dynamically typed, nullable single value. This is the single-valued counter-part to arrow’s [Array].

See datatypes for details on datatypes and the format for the definitive reference.

Variants§

§

Null

represents DataType::Null (castable to/from any other type)

§

Boolean(Option<bool>)

true or false value

§

Float32(Option<f32>)

32bit float

§

Float64(Option<f64>)

64bit float

§

Decimal128(Option<i128>, u8i8)

128bit decimal, using the i128 to represent the decimal, precision scale

§

Int8(Option<i8>)

signed 8bit int

§

Int16(Option<i16>)

signed 16bit int

§

Int32(Option<i32>)

signed 32bit int

§

Int64(Option<i64>)

signed 64bit int

§

UInt8(Option<u8>)

unsigned 8bit int

§

UInt16(Option<u16>)

unsigned 16bit int

§

UInt32(Option<u32>)

unsigned 32bit int

§

UInt64(Option<u64>)

unsigned 64bit int

§

Utf8(Option<String>)

utf-8 encoded string.

§

LargeUtf8(Option<String>)

utf-8 encoded string representing a LargeString’s arrow type.

§

Binary(Option<Vec<u8, Global>>)

binary

§

FixedSizeBinary(i32Option<Vec<u8, Global>>)

fixed size binary

§

LargeBinary(Option<Vec<u8, Global>>)

large binary

§

List(Option<Vec<ScalarValue, Global>>, Box<Field, Global>)

list of nested ScalarValue

§

Date32(Option<i32>)

Date stored as a signed 32bit int days since UNIX epoch 1970-01-01

§

Date64(Option<i64>)

Date stored as a signed 64bit int milliseconds since UNIX epoch 1970-01-01

§

Time32Second(Option<i32>)

Time stored as a signed 32bit int as seconds since midnight

§

Time32Millisecond(Option<i32>)

Time stored as a signed 32bit int as milliseconds since midnight

§

Time64Microsecond(Option<i64>)

Time stored as a signed 64bit int as microseconds since midnight

§

Time64Nanosecond(Option<i64>)

Time stored as a signed 64bit int as nanoseconds since midnight

§

TimestampSecond(Option<i64>, Option<String>)

Timestamp Second

§

TimestampMillisecond(Option<i64>, Option<String>)

Timestamp Milliseconds

§

TimestampMicrosecond(Option<i64>, Option<String>)

Timestamp Microseconds

§

TimestampNanosecond(Option<i64>, Option<String>)

Timestamp Nanoseconds

§

IntervalYearMonth(Option<i32>)

Number of elapsed whole months

§

IntervalDayTime(Option<i64>)

Number of elapsed days and milliseconds (no leap seconds) stored as 2 contiguous 32-bit signed integers

§

IntervalMonthDayNano(Option<i128>)

A triple of the number of elapsed months, days, and nanoseconds. Months and days are encoded as 32-bit signed integers. Nanoseconds is encoded as a 64-bit signed integer (no leap seconds).

§

Struct(Option<Vec<ScalarValue, Global>>, Box<Vec<Field, Global>, Global>)

struct of nested ScalarValue

§

Dictionary(Box<DataType, Global>, Box<ScalarValue, Global>)

Dictionary type: index type and value

Implementations§

Create a decimal Scalar from value/precision and scale.

Returns a ScalarValue::Utf8 representing val

Returns a ScalarValue::IntervalYearMonth representing years years and months months

Returns a ScalarValue::IntervalDayTime representing days days and millis milliseconds

Returns a ScalarValue::IntervalMonthDayNano representing months months and days days, and nanos nanoseconds

Create a new nullable ScalarValue::List with the specified child_type

Getter for the DataType of the value

Calculate arithmetic negation for a scalar value

whether this value is null or not.

Absolute distance between two numeric values (of the same type). This method will return None if either one of the arguments are null. It might also return None if the resulting distance is greater than usize::MAX. If the type is a float, then the distance will be rounded to the nearest integer.

Note: the datatype itself must support subtraction.

Converts a scalar value into an 1-row array.

Converts an iterator of references ScalarValue into an [ArrayRef] corresponding to those values. For example,

Returns an error if the iterator is empty or if the ScalarValues are not all the same type

Example

use datafusion_common::ScalarValue;
use arrow::array::{ArrayRef, BooleanArray};

let scalars = vec![
  ScalarValue::Boolean(Some(true)),
  ScalarValue::Boolean(None),
  ScalarValue::Boolean(Some(false)),
];

// Build an Array from the list of ScalarValues
let array = ScalarValue::iter_to_array(scalars.into_iter())
  .unwrap();

let expected: ArrayRef = std::sync::Arc::new(
  BooleanArray::from(vec![
    Some(true),
    None,
    Some(false)
  ]
));

assert_eq!(&array, &expected);

Converts a scalar value into an array of size rows.

Converts a value in array at index into a ScalarValue

Try to parse value into a ScalarValue of type target_type

Compares a single row of array @ index for equality with self, in an optimized fashion.

This method implements an optimized version of:

    let arr_scalar = Self::try_from_array(array, index).unwrap();
    arr_scalar.eq(self)

Performance note: the arrow compute kernels should be preferred over this function if at all possible as they can be vectorized and are generally much faster.

This function has a few narrow usescases such as hash table key comparisons where comparing a single row at a time is necessary.

Estimate size if bytes including Self. For values with internal containers such as String includes the allocated size (capacity) rather than the current length (len)

Estimates size of Vec in bytes.

Includes the size of the Vec container itself.

Estimates size of HashSet in bytes.

Includes the size of the HashSet container itself.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Formats the value using the given formatter. Read more
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
The associated error which can be returned from parsing.
Parses a string s to return a value of this type. Read more
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
convert the value to a Literal expression
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Create a Null instance of ScalarValue for this datatype

The type returned in the event of a conversion error.

Create a Null instance of ScalarValue for this datatype

The type returned in the event of a conversion error.
The type returned in the event of a conversion error.
Performs the conversion.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Checks if this value is equivalent to the given key. Read more
Compare self to key and return true if they are equal.

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
Converts the given value to a String. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.