Apache.Calcite.Data.Common
2.0.1-pre.267
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
<PackageReference Include="Apache.Calcite.Data.Common" Version="2.0.1-pre.267" />
<PackageVersion Include="Apache.Calcite.Data.Common" Version="2.0.1-pre.267" />
<PackageReference Include="Apache.Calcite.Data.Common" />
paket add Apache.Calcite.Data.Common --version 2.0.1-pre.267
#r "nuget: Apache.Calcite.Data.Common, 2.0.1-pre.267"
#:package Apache.Calcite.Data.Common@2.0.1-pre.267
#addin nuget:?package=Apache.Calcite.Data.Common&version=2.0.1-pre.267&prerelease
#tool nuget:?package=Apache.Calcite.Data.Common&version=2.0.1-pre.267&prerelease
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
toCalcitemust return an instance of the Java class Calcite holds the type in (as decided by the session'sJavaTypeFactory.getJavaClass); the first value a mapping converts is checked, and a mismatch throwsClrTypeMappingException. PrependandAppendreplace any resolver of the same runtime type already in the chain, so twoClrTypeMappingCollectioninstances cannot both be registered; put all the entries in one, or implementIClrTypeResolveron a class of your own.- Add all entries to a
ClrTypeMappingCollectionbefore registering it. - A connection reads its chain when it first opens;
TypeMapperthrows after that. - For a mapping that needs more than two delegates, derive from
ClrTypeMappingand add the entry with aClrTypeMappingFactory, or implementIClrTypeResolver.GetMappingdirectly.
| Product | Versions 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. |
-
net8.0
- Apache.Calcite.Extensions (>= 2.0.1-pre.267)
- IKVM (>= 8.16.1)
- IKVM.Java.Extensions (>= 8.16.1)
- IKVM.Maven.Sdk (>= 1.12.1)
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 |