-
Notifications
You must be signed in to change notification settings - Fork 8
Logging: virtual table schema #295
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 12 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
ced5acf
Schema provider
vitalyisaev2 e654c61
Rows.MakeTransformer: interface change
vitalyisaev2 5f98cc4
Not operational
vitalyisaev2 787c9f6
type_mapper.go -> type_mapping.go
vitalyisaev2 a1cd093
Custom type mapping for ERROR column
vitalyisaev2 1806686
TransformSelectWhat (not operational)
vitalyisaev2 91bb5c5
Successfully read data with transformation
vitalyisaev2 04913bc
Not operational
vitalyisaev2 62e2bc8
Managed to transform predicate
vitalyisaev2 c731cec
Logging SQL Formatter unit test
vitalyisaev2 22006b4
Fix optional
vitalyisaev2 da40ffd
Minor changes
vitalyisaev2 701942d
Add constant
vitalyisaev2 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
File renamed without changes.
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,37 @@ | ||
package logging | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/ydb-platform/ydb-go-genproto/protos/Ydb" | ||
|
||
"github.com/ydb-platform/fq-connector-go/app/server/conversion" | ||
rdbms_utils "github.com/ydb-platform/fq-connector-go/app/server/datasource/rdbms/utils" | ||
"github.com/ydb-platform/fq-connector-go/app/server/paging" | ||
) | ||
|
||
var _ rdbms_utils.Rows = (*rowsImpl)(nil) | ||
|
||
type rowsImpl struct { | ||
rdbms_utils.Rows | ||
} | ||
|
||
func (rowsImpl) MakeTransformer(ydbColumns []*Ydb.Column, cc conversion.Collection) (paging.RowTransformer[any], error) { | ||
return makeRowTransformer(ydbColumns, cc) | ||
} | ||
|
||
var _ rdbms_utils.Connection = (*connectionImpl)(nil) | ||
|
||
type connectionImpl struct { | ||
rdbms_utils.Connection | ||
} | ||
|
||
func (c *connectionImpl) Query(params *rdbms_utils.QueryParams) (rdbms_utils.Rows, error) { | ||
ydbRows, err := c.Connection.Query(params) | ||
if err != nil { | ||
return nil, fmt.Errorf("ydb connection query: %w", err) | ||
} | ||
|
||
// Wrap YDB row iterator with new implementation that uses custom transformer | ||
return &rowsImpl{Rows: ydbRows}, nil | ||
} |
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,15 @@ | ||
package logging | ||
|
||
const ( | ||
levelColumnName = "level" | ||
timestampColumnName = "timestamp" | ||
messageColumnName = "message" | ||
metaColumnName = "meta" | ||
|
||
levelTraceValue = "TRACE" | ||
levelDebugValue = "DEBUG" | ||
levelInfoValue = "INFO" | ||
levelWarnValue = "WARN" | ||
levelErrorValue = "ERROR" | ||
levelFatalValue = "FATAL" | ||
) |
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,40 @@ | ||
package logging | ||
|
||
import ( | ||
"context" | ||
|
||
"go.uber.org/zap" | ||
|
||
"github.com/ydb-platform/ydb-go-genproto/protos/Ydb" | ||
|
||
api_service_protos "github.com/ydb-platform/fq-connector-go/api/service/protos" | ||
rdbms_utils "github.com/ydb-platform/fq-connector-go/app/server/datasource/rdbms/utils" | ||
"github.com/ydb-platform/fq-connector-go/common" | ||
) | ||
|
||
var loggingVirtualSchema = &api_service_protos.TSchema{ | ||
Columns: []*Ydb.Column{ | ||
{Name: levelColumnName, Type: common.MakeOptionalType(common.MakePrimitiveType(Ydb.Type_UTF8))}, | ||
{Name: timestampColumnName, Type: common.MakeOptionalType(common.MakePrimitiveType(Ydb.Type_TIMESTAMP))}, | ||
{Name: messageColumnName, Type: common.MakeOptionalType(common.MakePrimitiveType(Ydb.Type_UTF8))}, | ||
{Name: metaColumnName, Type: common.MakeOptionalType(common.MakePrimitiveType(Ydb.Type_JSON))}, | ||
}, | ||
} | ||
|
||
var _ rdbms_utils.SchemaProvider = (*schemaProviderImpl)(nil) | ||
|
||
type schemaProviderImpl struct { | ||
} | ||
|
||
func (schemaProviderImpl) GetSchema( | ||
_ context.Context, | ||
_ *zap.Logger, | ||
_ rdbms_utils.Connection, | ||
_ *api_service_protos.TDescribeTableRequest, | ||
) (*api_service_protos.TSchema, error) { | ||
return loggingVirtualSchema, nil | ||
} | ||
|
||
func NewSchemaProvider() rdbms_utils.SchemaProvider { | ||
return &schemaProviderImpl{} | ||
} |
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.
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.
Uh oh!
There was an error while loading. Please reload this page.