Apache.Calcite.Data.Common 2.0.1-pre.267

This is a prerelease version of Apache.Calcite.Data.Common.
dotnet add package Apache.Calcite.Data.Common --version 2.0.1-pre.267
                    
NuGet\Install-Package Apache.Calcite.Data.Common -Version 2.0.1-pre.267
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Apache.Calcite.Data.Common" Version="2.0.1-pre.267" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Apache.Calcite.Data.Common" Version="2.0.1-pre.267" />
                    
Directory.Packages.props
<PackageReference Include="Apache.Calcite.Data.Common" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Apache.Calcite.Data.Common --version 2.0.1-pre.267
                    
#r "nuget: Apache.Calcite.Data.Common, 2.0.1-pre.267"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Apache.Calcite.Data.Common@2.0.1-pre.267
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Apache.Calcite.Data.Common&version=2.0.1-pre.267&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Apache.Calcite.Data.Common&version=2.0.1-pre.267&prerelease
                    
Install as a Cake Tool

Apache.Calcite.Data.Common

The CLR type mapping shared by the Apache Calcite ADO.NET provider (Apache.Calcite.Data) and the ADO.NET adapter (Apache.Calcite.Adapter.AdoNet): which .NET type each Calcite SQL type is presented as, and how values are converted between the two in both directions.

Calcite holds values in Java classes: a DATE is a count of days in a java.lang.Integer, a DECIMAL a java.math.BigDecimal, a UTINYINT an org.joou.UByte. .NET code wants a DateTime, a decimal, a byte. This package decides that mapping for reading result columns, binding command parameters, reading an ADO.NET provider's rows into a plan, and typing tables.

You normally get this package as a dependency of Apache.Calcite.Data. Reference it directly only to write your own type resolver.

The built-in mappings

DefaultClrTypeResolver maps every standard Calcite type. Among others:

Calcite type .NET type read notes
BOOLEAN, TINYINT, SMALLINT, INTEGER, BIGINT bool, sbyte, short, int, long
UTINYINT, USMALLINT, UINTEGER, UBIGINT byte, ushort, uint, ulong
REAL, DOUBLE, FLOAT float, double, double
DECIMAL decimal a BigInteger parameter is written as DECIMAL
CHAR, VARCHAR string a char parameter is written as CHAR(1)
BINARY, VARBINARY byte[]
DATE, TIMESTAMP DateTime a DateTime parameter is written as TIMESTAMP, a DateOnly as DATE
TIME TimeSpan a TimeOnly parameter is written as TIME
zoned TIME and TIMESTAMP types DateTimeOffset
UUID Guid
GEOMETRY string well-known text
year-month intervals int a count of months
day-time intervals TimeSpan millisecond precision
ARRAY, MULTISET an array of the element type e.g. int?[] for a nullable INTEGER element
MAP Dictionary<TKey, TValue> an array of KeyValuePair where the key type is nullable
ROW object[]
ANY, OTHER, VARIANT object each value mapped by its own type

A caller asking for a specific type can also read TIMESTAMP as DateOnly, TimeOnly or DateTimeOffset, TIMESTAMP WITH TIME ZONE as DateTime, and an array's elements as any type their element type maps to (for example a DATE ARRAY as DateOnly[]). A type not listed has no mapping unless a resolver of your own provides one.

Adding your own mapping

Mappings come from a chain of IClrTypeResolvers; the first non-null answer wins. To present a type differently, put a resolver in front of the built-in one. ClrTypeMappingCollection is a ready-made resolver built from a table:

using Apache.Calcite.Data.Common;
using org.apache.calcite.sql.type;

var mappings = new ClrTypeMappingCollection();

// An EmailAddress parameter is written as VARCHAR, and a VARCHAR column can be read as an EmailAddress
// when asked for by name (GetFieldValue<EmailAddress>). VARCHAR columns still read as string by default.
mappings.Add(
    typeof(EmailAddress),
    SqlTypeName.VARCHAR,
    toCalcite: v => ((EmailAddress)v).Value,
    fromCalcite: v => new EmailAddress((string)v),
    match: ClrTypeMatch.ClrDefault);

Register it for every connection of a data source:

var dataSource = new CalciteDataSourceBuilder(connectionString)
    .AddTypeResolver(mappings)
    .Build();

or for one connection, before it is opened:

connection.TypeMapper.Prepend(mappings);
connection.Open();

ClrTypeMatch says which lookups an entry answers when only one of the two types is known: RelDefault makes the CLR type what the Calcite type reads as by default, ClrDefault makes the Calcite type what a bare value of the CLR type is written as, and Named answers only when both are asked for.

Things to know:

  • A conversion is given a non-null value, and toCalcite must return an instance of the Java class Calcite holds the type in (as decided by the session's JavaTypeFactory.getJavaClass); the first value a mapping converts is checked, and a mismatch throws ClrTypeMappingException.
  • Prepend and Append replace any resolver of the same runtime type already in the chain, so two ClrTypeMappingCollection instances cannot both be registered; put all the entries in one, or implement IClrTypeResolver on a class of your own.
  • Add all entries to a ClrTypeMappingCollection before registering it.
  • A connection reads its chain when it first opens; TypeMapper throws after that.
  • For a mapping that needs more than two delegates, derive from ClrTypeMapping and add the entry with a ClrTypeMappingFactory, or implement IClrTypeResolver.GetMapping directly.
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Apache.Calcite.Data.Common:

Package Downloads
Apache.Calcite.Data

Apache Calcite for ADO.NET. A native, in-process ADO.NET provider that runs the Apache Calcite SQL parser, planner, and runtime via IKVM.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.1-pre.267 0 9/28/2026
2.0.1-pre.254 0 9/28/2026
2.0.1-pre.250 0 9/27/2026
2.0.1-pre.236 44 9/26/2026
2.0.1-pre.230 41 9/26/2026
2.0.1-pre.190 156 9/20/2026
2.0.1-pre.188 172 9/19/2026