Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
af0aecd
fixes and additions working towards getting C# client to 2.2
stephenatsembit Feb 4, 2026
adc3940
populate missing table columns when returning untyped table data
stephenatsembit Feb 5, 2026
4e3659a
adjust vector tests
stephenatsembit Feb 5, 2026
c8ca2d4
fix index definition serialization
stephenatsembit Feb 5, 2026
c4ba070
Create default_keyspace as part of HCD setup for IT (#30)
sl-at-ibm Feb 20, 2026
72a5b6d
Fix: Table FindOne by Vector, IncludeSimilarity for untyped Rows
stephenatsembit Feb 25, 2026
5545859
cache table info when returning many untyped rows
stephenatsembit Feb 26, 2026
342fb40
add ability to skip tests that are only for astra
stephenatsembit Feb 27, 2026
502cf15
fix typo in documentation
stephenatsembit Mar 2, 2026
3c4bb80
hcd all green!
a-random-steve Mar 2, 2026
52ae77c
mods for running tests in astra
stephenatsembit Mar 3, 2026
2f711e2
few additional fixes for astra tests
stephenatsembit Mar 3, 2026
11018ad
fixes and additions working towards getting C# client to 2.2
stephenatsembit Feb 4, 2026
1611580
populate missing table columns when returning untyped table data
stephenatsembit Feb 5, 2026
1c30882
fix index definition serialization
stephenatsembit Feb 5, 2026
0beece1
add ability to skip tests that are only for astra
stephenatsembit Feb 27, 2026
0954dba
fix typo in documentation
stephenatsembit Mar 2, 2026
85f2175
hcd all green!
a-random-steve Mar 2, 2026
be258c9
mods for running tests in astra
stephenatsembit Mar 3, 2026
a952a0b
few additional fixes for astra tests
stephenatsembit Mar 3, 2026
a476c29
fix merge issue
stephenatsembit Mar 3, 2026
1d68f19
update table to use projectionSchema to fill in missing columns on un…
stephenatsembit Mar 3, 2026
aba1da0
Merge branch 'hcd-passing-tests' of https://github.com/a-random-steve…
stephenatsembit Mar 3, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/DataStax.AstraDB.DataApi/Admin/DatabaseAdminOther.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ namespace DataStax.AstraDB.DataApi.Admin
/// </remarks>
public class DatabaseAdminOther : IDatabaseAdmin
{
private readonly Guid? _id;
private readonly Database _database;
private readonly CommandOptions _adminOptions;
private readonly DataApiClient _client;
Expand Down
3 changes: 2 additions & 1 deletion src/DataStax.AstraDB.DataApi/Core/CommandUrlBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ internal EmbeddingCommandUrlBuilder(Database database)

internal override string BuildUrl(CommandOptions options)
{
var url = $"{_database.ApiEndpoint}/api/json/{options.ApiVersion.Value.ToUrlString()}";
var prefix = options.Destination == DataApiDestination.ASTRA ? "api/json/" : "";
var url = $"{_database.ApiEndpoint}/{prefix}{options.ApiVersion.Value.ToUrlString()}";
return url;
}
}
6 changes: 5 additions & 1 deletion src/DataStax.AstraDB.DataApi/Core/Database.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,11 @@ internal Database(string apiEndpoint, DataApiClient client, DatabaseCommandOptio
_apiEndpoint = apiEndpoint;
_client = client;
_dbCommandOptions = dbCommandOptions;
_id = GetDatabaseIdFromUrl(_apiEndpoint);
var maybeId = GetDatabaseIdFromUrl(_apiEndpoint);
if (maybeId != null)
{
_id = (Guid)maybeId;
}
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public enum RerankingProviderStatus
}

/// <summary>
/// Options for Find Available Regions command.
/// Options for Find Reranking Providers command.
/// </summary>
public class FindRerankingProvidersCommandOptions : CommandOptions
{
Expand Down
2 changes: 1 addition & 1 deletion src/DataStax.AstraDB.DataApi/Core/Query/IQueryRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ internal interface IQueryRunner<TBase, TSort> where TSort : SortBuilder<TBase>
internal Task<ApiResponseWithData<ApiFindResult<TProjected>, FindStatusResult>> RunFindManyAsync<TProjected>(
Filter<TBase> filter, IFindManyOptions<TBase, TSort> findOptions, CommandOptions commandOptions, bool runSynchronously)
where TProjected : class;
}
}
22 changes: 21 additions & 1 deletion src/DataStax.AstraDB.DataApi/Core/Results/FindStatusResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ internal class FindStatusResult
[JsonInclude]
[JsonPropertyName("sortVector")]
internal float[] SortVector { get; set; }

}

internal class FindStatusResult<T> : FindStatusResult
Expand All @@ -33,3 +32,24 @@ internal class FindStatusResult<T> : FindStatusResult
[JsonPropertyName("documentResponses")]
internal List<T> DocumentResponses { get; set; }
}

internal class TableFindStatusResult : FindStatusResult
{
[JsonInclude]
[JsonPropertyName("projectionSchema")]
internal Dictionary<string, SchemaColumn> ProjectionSchema { get; set; }
}

internal class TableFindStatusResult<T> : TableFindStatusResult
{
[JsonInclude]
[JsonPropertyName("documentResponses")]
internal List<T> DocumentResponses { get; set; }
}

internal class SchemaColumn
{
[JsonInclude]
[JsonPropertyName("type")]
public string Type { get; set; }
}
47 changes: 25 additions & 22 deletions src/DataStax.AstraDB.DataApi/Tables/Table.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
private readonly string _tableName;
private readonly Database _database;
private readonly CommandOptions _commandOptions;
private TableInfo _cachedTableInfo;

internal Table(string tableName, Database database, CommandOptions commandOptions)
{
Expand Down Expand Up @@ -706,11 +705,11 @@
/// <summary>
/// Find rows in the table.
///
/// The Find() methods return a <see cref="FindEnumerator{T,T,TableSortBuilder{T}}"/> object that can be used to further structure the query

Check warning on line 708 in src/DataStax.AstraDB.DataApi/Tables/Table.cs

View workflow job for this annotation

GitHub Actions / test

Type parameter declaration must be an identifier not a type. See also error CS0081.

Check warning on line 708 in src/DataStax.AstraDB.DataApi/Tables/Table.cs

View workflow job for this annotation

GitHub Actions / test

XML comment has syntactically incorrect cref attribute 'FindEnumerator{T,T,TableSortBuilder{T}}'

Check warning on line 708 in src/DataStax.AstraDB.DataApi/Tables/Table.cs

View workflow job for this annotation

GitHub Actions / build

Type parameter declaration must be an identifier not a type. See also error CS0081.

Check warning on line 708 in src/DataStax.AstraDB.DataApi/Tables/Table.cs

View workflow job for this annotation

GitHub Actions / build

XML comment has syntactically incorrect cref attribute 'FindEnumerator{T,T,TableSortBuilder{T}}'
/// by adding Sort, Projection, Skip, Limit, etc. to affect the final results.
///
/// The <see cref="FindEnumerator{T,T,TableSortBuilder{T}}"/> object can be directly enumerated both synchronously and asynchronously.

Check warning on line 711 in src/DataStax.AstraDB.DataApi/Tables/Table.cs

View workflow job for this annotation

GitHub Actions / test

Type parameter declaration must be an identifier not a type. See also error CS0081.

Check warning on line 711 in src/DataStax.AstraDB.DataApi/Tables/Table.cs

View workflow job for this annotation

GitHub Actions / test

XML comment has syntactically incorrect cref attribute 'FindEnumerator{T,T,TableSortBuilder{T}}'

Check warning on line 711 in src/DataStax.AstraDB.DataApi/Tables/Table.cs

View workflow job for this annotation

GitHub Actions / build

Type parameter declaration must be an identifier not a type. See also error CS0081.

Check warning on line 711 in src/DataStax.AstraDB.DataApi/Tables/Table.cs

View workflow job for this annotation

GitHub Actions / build

XML comment has syntactically incorrect cref attribute 'FindEnumerator{T,T,TableSortBuilder{T}}'
/// Secondarily, the results can be paged through manually by using the results of <see cref="FindEnumerator{T,T,TableSortBuilder{T}}.ToCursor()"/>.

Check warning on line 712 in src/DataStax.AstraDB.DataApi/Tables/Table.cs

View workflow job for this annotation

GitHub Actions / test

XML comment has syntactically incorrect cref attribute 'FindEnumerator{T,T,TableSortBuilder{T}}.ToCursor()'

Check warning on line 712 in src/DataStax.AstraDB.DataApi/Tables/Table.cs

View workflow job for this annotation

GitHub Actions / build

Type parameter declaration must be an identifier not a type. See also error CS0081.

Check warning on line 712 in src/DataStax.AstraDB.DataApi/Tables/Table.cs

View workflow job for this annotation

GitHub Actions / build

XML comment has syntactically incorrect cref attribute 'FindEnumerator{T,T,TableSortBuilder{T}}.ToCursor()'
/// </summary>
/// <returns></returns>
/// <example>
Expand Down Expand Up @@ -787,7 +786,7 @@
return new FindEnumerator<T, TResult, TableSortBuilder<T>>(this, findOptions, commandOptions);
}

internal async Task<ApiResponseWithData<ApiFindResult<TResult>, FindStatusResult>> RunFindManyAsync<TResult>(
internal async Task<ApiResponseWithData<ApiFindResult<TResult>, TableFindStatusResult>> RunFindManyAsync<TResult>(
Filter<T> filter,
IFindManyOptions<T,
TableSortBuilder<T>> findOptions,
Expand All @@ -799,17 +798,16 @@
findOptions.Filter = filter;
commandOptions = SetRowSerializationOptions<TResult>(commandOptions, false);
var command = CreateCommand("find").WithPayload(findOptions).AddCommandOptions(commandOptions);
var response = await command.RunAsyncReturnData<ApiFindResult<TResult>, FindStatusResult>(runSynchronously).ConfigureAwait(false);
var response = await command.RunAsyncReturnData<ApiFindResult<TResult>, TableFindStatusResult>(runSynchronously).ConfigureAwait(false);
if (typeof(Row).IsAssignableFrom(typeof(TResult)))
{
if (_cachedTableInfo == null)
var columnsInResult = response.Status.ProjectionSchema;
if (response != null && response.Data != null && response.Data.Items != null)
{
var tableInfos = runSynchronously ? _database.ListTables() : await _database.ListTablesAsync();
_cachedTableInfo = tableInfos.FirstOrDefault(t => t.Name == _tableName);
}
foreach (var row in response.Data.Items)
{
PopulateMissingColumnsInRow(row as Row, _cachedTableInfo);
foreach (var row in response.Data.Items)
{
PopulateMissingColumnsInRow(row as Row, columnsInResult);
}
}
}
return response;
Expand Down Expand Up @@ -1000,26 +998,25 @@
}
commandOptions = SetRowSerializationOptions<TResult>(commandOptions, false);
var command = CreateCommand("findOne").WithPayload(findOptions).AddCommandOptions(commandOptions);
var response = await command.RunAsyncReturnData<DocumentResult<TResult>, FindStatusResult>(runSynchronously).ConfigureAwait(false);
var response = await command.RunAsyncReturnData<DocumentResult<TResult>, TableFindStatusResult>(runSynchronously).ConfigureAwait(false);
if (typeof(Row).IsAssignableFrom(typeof(TResult)))
{
// we are going to get the table definition and handle null values for missing columns
var tableInfos = runSynchronously ? _database.ListTables() : await _database.ListTablesAsync();
var tableInfo = tableInfos.FirstOrDefault(t => t.Name == _tableName);
PopulateMissingColumnsInRow(response.Data.Document as Row, tableInfo);

if (response != null && response.Data != null && response.Data.Document != null)
{
PopulateMissingColumnsInRow(response.Data.Document as Row, response.Status.ProjectionSchema);
}
}
return response.Data.Document;
}

private void PopulateMissingColumnsInRow(Row row, TableInfo tableInfo)
private void PopulateMissingColumnsInRow(Row row, Dictionary<string, SchemaColumn> projectionSchema)
{
foreach (var column in tableInfo.TableDefinition.Columns)
foreach (var column in projectionSchema)
{
if (!row.ContainsKey(column.Key))
{
object value = null;
var columnType = ((Dictionary<string, object>)column.Value)["type"];
var columnType = column.Value.Type;
switch (columnType)
{
case "map":
Expand Down Expand Up @@ -1433,9 +1430,15 @@
return new Command(name, _database.Client, optionsTree, new DatabaseCommandUrlBuilder(_database, _tableName));
}

Task<ApiResponseWithData<ApiFindResult<TProjected>, FindStatusResult>> IQueryRunner<T, TableSortBuilder<T>>.RunFindManyAsync<TProjected>(Filter<T> filter, IFindManyOptions<T, TableSortBuilder<T>> findOptions, CommandOptions commandOptions, bool runSynchronously)
where TProjected : class
async Task<ApiResponseWithData<ApiFindResult<TProjected>, FindStatusResult>> IQueryRunner<T, TableSortBuilder<T>>.RunFindManyAsync<TProjected>(Filter<T> filter, IFindManyOptions<T, TableSortBuilder<T>> findOptions, CommandOptions commandOptions, bool runSynchronously)
{
return RunFindManyAsync<TProjected>(filter, findOptions, commandOptions, runSynchronously);
var result = await RunFindManyAsync<TProjected>(filter, findOptions, commandOptions, runSynchronously).ConfigureAwait(false);
return new ApiResponseWithData<ApiFindResult<TProjected>, FindStatusResult>
{
Data = result.Data,
Status = result.Status,
Errors = result.Errors,
Warnings = result.Warnings
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@ public class AdminFixture : BaseFixture
public AdminFixture(AssemblyFixture assemblyFixture) : base(assemblyFixture, "admin")
{
DatabaseName = assemblyFixture.DatabaseName;
DatabaseId = GetDatabaseIdFromUrl(assemblyFixture.DatabaseUrl).Value;
var dbId = GetDatabaseIdFromUrl(assemblyFixture.DatabaseUrl);
if (dbId != null)
{
DatabaseId = dbId.Value;
}
}

public DatabaseAdminAstra CreateAdmin(Database database = null)
public IDatabaseAdmin CreateAdmin(Database database = null)
{
database ??= Database;

Expand All @@ -25,7 +29,11 @@ public DatabaseAdminAstra CreateAdmin(Database database = null)
Environment = DBEnvironment.Production // or default
};

return new DatabaseAdminAstra(database, Client, adminOptions);
if (Destination.ToLower() == "astra") {
return new DatabaseAdminAstra(database, Client, adminOptions);
}

return new DatabaseAdminOther(database, Client, adminOptions);
}

public static Guid? GetDatabaseIdFromUrl(string url)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class AssemblyFixture

public string DatabaseUrl { get; private set; }
public string DatabaseName { get; private set; }
public string Destination { get; private set; }
public string Destination { get; private set; } = "astra";

public AssemblyFixture()
{
Expand All @@ -30,7 +30,7 @@ public AssemblyFixture()
OpenAiApiKey = configuration["OPENAI_APIKEYNAME"] ?? configuration["AstraDB:OpenAiApiKey"];
DatabaseName = configuration["DATABASE_NAME"] ?? configuration["AstraDB:DatabaseName"];
DatabaseUrl = configuration["URL"] ?? configuration["AstraDB:Url"];
Destination = configuration["DESTINATION"] ?? configuration["AstraDB:Destination"];
Destination = configuration["DESTINATION"] ?? configuration["AstraDB:Destination"] ?? "astra";

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class BaseFixture
public DataApiClient ClientWithoutToken { get; set; }
public string DatabaseUrl { get; set; }
public string Token { get; set; }
public string Destination => _assemblyFixture.Destination;

public BaseFixture(AssemblyFixture assemblyFixture, string fixtureName)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
using DataStax.AstraDB.DataApi.SerDes;
using System.Text.Json.Serialization;
using Xunit;
using Xunit.v3;
using Xunit.Sdk;

namespace DataStax.AstraDB.DataApi.IntegrationTests.Fixtures;

Expand All @@ -24,6 +26,10 @@ public RerankFixture(AssemblyFixture assemblyFixture) : base(assemblyFixture, "r

public async ValueTask InitializeAsync()
{
if (Destination?.ToLower() != "astra")
{
return;
}
await CreateSearchCollection();
var collection = Database.GetCollection<HybridSearchTestObject>(_queryCollectionName);
HybridSearchCollection = collection;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using Microsoft.Extensions.Configuration;
using System.Reflection;
using Xunit.v3;

namespace DataStax.AstraDB.DataApi.IntegrationTests.Fixtures;

[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class)]
public class SkipWhenNotAstraAttribute : BeforeAfterTestAttribute
{
private static readonly Lazy<string> _destination = new(() =>
{
var config = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", optional: true)
.AddEnvironmentVariables(prefix: "ASTRA_DB_")
.Build();
return (config["DESTINATION"] ?? config["AstraDB:Destination"])?.ToLower();
});

public override void Before(MethodInfo methodUnderTest, IXunitTest test)
{
var destination = _destination.Value;
if (!string.IsNullOrEmpty(destination) && destination != "astra")
throw new Exception($"{DynamicSkipToken.Value}Requires Astra destination (current: '{destination}')");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,7 @@ public class TableAlterFixture : BaseFixture
{
public TableAlterFixture(AssemblyFixture assemblyFixture) : base(assemblyFixture, "tableAlter")
{
try
{
var keyspaces = Database.GetAdmin().ListKeyspaces();
Console.WriteLine($"[Fixture] Connected. Keyspaces found: {keyspaces.Count()}");
}
catch (Exception ex)
{
Console.WriteLine($"[Fixture] Connection failed: {ex.Message}");
throw;
}

}

public async Task<Table<RowEventByDay>> CreateTestTable(string tableName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,7 @@ public class TableIndexesFixture : BaseFixture, IAsyncLifetime
{
public TableIndexesFixture(AssemblyFixture assemblyFixture) : base(assemblyFixture, "tableIndexes")
{
try
{
var keyspaces = Database.GetAdmin().ListKeyspaces();
Console.WriteLine($"[Fixture] Connected. Keyspaces found: {keyspaces.Count()}");
}
catch (Exception ex)
{
Console.WriteLine($"[Fixture] Connection failed: {ex.Message}");
throw;
}

}

public Table<RowEventByDay> FixtureTestTable { get; private set; }
Expand Down
Loading
Loading