ptupitsyn commented on issue #10746:
URL: https://github.com/apache/ignite/issues/10746#issuecomment-1566857529
Adding or deleting a column with SQL API should be fairly quick, because it
does not modify the data. The data is always stored in schemaless format
(key/value pairs).
For example:
```csharp
using Apache.Ignite.Core;
using Apache.Ignite.Core.Cache.Configuration;
using Apache.Ignite.Core.Cache.Query;
var ignite = Ignition.Start();
var cfg = new CacheConfiguration("c", new QueryEntity(typeof(Person)));
var cache = ignite.GetOrCreateCache<int, Person>(cfg);
cache[1] = new Person(1, "Foo", 123);
Query("SELECT * FROM PERSON");
Query("ALTER TABLE Person ADD COLUMN Age INT");
Query("SELECT * FROM PERSON");
Query("ALTER TABLE Person DROP COLUMN Age");
// "Age" value is not affected by DDL.
Console.WriteLine("Person = " + cache[1]);
void Query(string sql)
{
Console.WriteLine(" >>> " + sql);
using var cursor = cache.Query(new SqlFieldsQuery(sql));
foreach (var name in cursor.FieldNames)
{
Console.Write($"{name}\t");
}
Console.WriteLine();
foreach (var row in cursor)
{
foreach (var val in row)
{
Console.Write($"{val}\t");
}
}
Console.WriteLine();
Console.WriteLine();
}
// Initial configuration does not include SQL Age column.
public record Person(
[property: QuerySqlField] int Id,
[property: QuerySqlField] string Name,
int Age);
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]