-
Notifications
You must be signed in to change notification settings - Fork 1
Add premium geo dimension columns to usage events #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| <?php | ||
|
|
||
| namespace Utopia\Tests\Adapter; | ||
|
|
||
| use PHPUnit\Framework\TestCase; | ||
| use ReflectionMethod; | ||
| use Utopia\Usage\Adapter\ClickHouse as ClickHouseAdapter; | ||
|
|
||
| /** | ||
| * Pure unit test (no live ClickHouse) for the private column-type mapping. | ||
| * The adapter constructor builds a lazy transport client and never connects, | ||
| * so getColumnType() can be exercised via reflection to assert the | ||
| * LowCardinality vs Nullable(String) decision per dimension column. | ||
| */ | ||
| class ClickHouseColumnTypeTest extends TestCase | ||
| { | ||
| private ClickHouseAdapter $adapter; | ||
|
|
||
| private ReflectionMethod $getColumnType; | ||
|
|
||
| protected function setUp(): void | ||
| { | ||
| $this->adapter = new ClickHouseAdapter( | ||
| 'clickhouse', | ||
| 'default', | ||
| '', | ||
| 8123, | ||
| false, | ||
| namespace: 'utopia_usage_coltype', | ||
| ); | ||
|
|
||
| $this->getColumnType = new ReflectionMethod(ClickHouseAdapter::class, 'getColumnType'); | ||
| $this->getColumnType->setAccessible(true); | ||
| } | ||
|
|
||
| private function columnType(string $id): string | ||
| { | ||
| /** @var string $type */ | ||
| $type = $this->getColumnType->invoke($this->adapter, $id, 'event'); | ||
| return $type; | ||
| } | ||
|
|
||
| /** | ||
| * Lower-cardinality premium geo dims must map to LowCardinality(Nullable(String)). | ||
| */ | ||
| public function testLowCardinalityPremiumGeoColumns(): void | ||
| { | ||
| foreach ([ | ||
| 'continentCode', 'subdivisions', 'connectionType', | ||
| 'connectionUsageType', 'autonomousSystemNumber', | ||
| ] as $col) { | ||
| $this->assertSame( | ||
| 'LowCardinality(Nullable(String))', | ||
| $this->columnType($col), | ||
| "{$col} should be LowCardinality(Nullable(String))" | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * High-cardinality premium geo dims must fall through to Nullable(String). | ||
| */ | ||
| public function testHighCardinalityPremiumGeoColumns(): void | ||
| { | ||
| foreach ([ | ||
| 'city', 'isp', 'autonomousSystemOrganization', 'connectionOrganization', | ||
| ] as $col) { | ||
| $this->assertSame( | ||
| 'Nullable(String)', | ||
| $this->columnType($col), | ||
| "{$col} should be plain Nullable(String)" | ||
| ); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
autonomousSystemNumberis defined withsize255 while every other new premium geo string column in the same block uses 256. Given that the other fields in this group (city,subdivisions,isp, etc.) all use 256, this looks like an accidental mismatch rather than a deliberate choice — ASNs are short strings, so the difference has no practical impact, but the inconsistency is worth correcting for schema coherence.Prompt To Fix With AI
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!