(
&mut self,
catalog_name: &str,
schema_name: &str,
table_name: &str,
field_position: usize,
field: &Field,
)
| 844 | |
| 845 | impl InformationSchemaColumnsBuilder { |
| 846 | fn add_column( |
| 847 | &mut self, |
| 848 | catalog_name: &str, |
| 849 | schema_name: &str, |
| 850 | table_name: &str, |
| 851 | field_position: usize, |
| 852 | field: &Field, |
| 853 | ) { |
| 854 | use DataType::*; |
| 855 | |
| 856 | // Note: append_value is actually infallible. |
| 857 | self.catalog_names.append_value(catalog_name); |
| 858 | self.schema_names.append_value(schema_name); |
| 859 | self.table_names.append_value(table_name); |
| 860 | |
| 861 | self.column_names.append_value(field.name()); |
| 862 | |
| 863 | self.ordinal_positions.append_value(field_position as u64); |
| 864 | |
| 865 | // DataFusion does not support column default values, so null |
| 866 | self.column_defaults.append_null(); |
| 867 | |
| 868 | // "YES if the column is possibly nullable, NO if it is known not nullable. " |
| 869 | let nullable_str = if field.is_nullable() { "YES" } else { "NO" }; |
| 870 | self.is_nullables.append_value(nullable_str); |
| 871 | |
| 872 | // "System supplied type" --> Use debug format of the datatype |
| 873 | self.data_types.append_value(field.data_type().to_string()); |
| 874 | |
| 875 | // "If data_type identifies a character or bit string type, the |
| 876 | // declared maximum length; null for all other data types or |
| 877 | // if no maximum length was declared." |
| 878 | // |
| 879 | // Arrow has no equivalent of VARCHAR(20), so we leave this as Null |
| 880 | let max_chars = None; |
| 881 | self.character_maximum_lengths.append_option(max_chars); |
| 882 | |
| 883 | // "Maximum length, in bytes, for binary data, character data, |
| 884 | // or text and image data." |
| 885 | let char_len: Option<u64> = match field.data_type() { |
| 886 | Utf8 | Binary => Some(i32::MAX as u64), |
| 887 | LargeBinary | LargeUtf8 => Some(i64::MAX as u64), |
| 888 | _ => None, |
| 889 | }; |
| 890 | self.character_octet_lengths.append_option(char_len); |
| 891 | |
| 892 | // numeric_precision: "If data_type identifies a numeric type, this column |
| 893 | // contains the (declared or implicit) precision of the type |
| 894 | // for this column. The precision indicates the number of |
| 895 | // significant digits. It can be expressed in decimal (base |
| 896 | // 10) or binary (base 2) terms, as specified in the column |
| 897 | // numeric_precision_radix. For all other data types, this |
| 898 | // column is null." |
| 899 | // |
| 900 | // numeric_radix: If data_type identifies a numeric type, this |
| 901 | // column indicates in which base the values in the columns |
| 902 | // numeric_precision and numeric_scale are expressed. The |
| 903 | // value is either 2 or 10. For all other data types, this |
no test coverage detected