crate / crate/crate-dbal

How to get column options

Open
#92 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
16
Forks
10
PR merge metrics
No merged PRs in 30d

Description

Hallo,
this is a follow up of my series #75 and #84.

I try to read the following table definition using DBAL:
```SQL
CREATE TABLE statusengine_logentries (
logentry_time timestamp,
entry_time timestamp,
logentry_type int,
logentry_data string,
node_name string,
day as date_trunc('day', logentry_time * 1000)
) CLUSTERED INTO 4 shards partitioned by (day) with (number_of_replicas = '0');
```

My issue is to read the `day` column with all options. I didn't find any method to read the `as date_trunc('day', logentry_time * 1000)` part of the column definition.

Thats my code:
```PHP
$connectionParams = [
'user' => null,
'password' => null,
'host' => '127.0.0.1',
'port' => 4200,
'driverClass' => 'Crate\DBAL\Driver\PDOCrate\Driver',
];
$connection = DriverManager::getConnection($connectionParams);
$platform = $connection->getDatabasePlatform();

$SchemaManager = $connection->getSchemaManager();

$schema = $SchemaManager->createSchema();

foreach ($schema->getTables() as $table) {
foreach ($table->getColumns() as $column) {
print_r($column->getCustomSchemaOptions()); //empty array
print_r($column->getPlatformOptions()); //empty array
}
}
```
I used crate-dbal 2.3.0 and CrateDB 4.1.6.

Contributor guide

Open the contributing guide

Research direction

Start with the schema manager entry point and the column metadata methods getCustomSchemaOptions() and getPlatformOptions() shown in the issue. Compare the metadata returned by crate-dbal 2.3.0 against the CrateDB 4.1.6 definition, and consider the work complete when the day column's AS expression and related options are exposed.

Written by the indexing model from the issue text.

Assessment

Tech stack
php, sql
Domain
databases
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.