-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Adds TLS support for native clickhouse connections. * Adds col Names for signal table.
- Loading branch information
1 parent
1ad6096
commit 0566b44
Showing
7 changed files
with
182 additions
and
72 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 clickhouseinfra | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/ClickHouse/clickhouse-go/v2" | ||
) | ||
|
||
// ColInfo is a struct that holds the column meta information. | ||
type ColInfo struct { | ||
Name string | ||
Type string | ||
Comment string | ||
} | ||
|
||
// GetCurrentCols returns the current columns of the table. | ||
func GetCurrentCols(ctx context.Context, chConn clickhouse.Conn, tableName string) ([]ColInfo, error) { | ||
selectStm := fmt.Sprintf("SELECT name, type, comment FROM system.columns where table='%s'", tableName) | ||
rows, err := chConn.Query(ctx, selectStm) | ||
if err != nil { | ||
return nil, fmt.Errorf("failed to show table: %w", err) | ||
} | ||
defer rows.Close() //nolint // we are not interested in the error here | ||
colInfos := []ColInfo{} | ||
count := 0 | ||
for rows.Next() { | ||
count++ | ||
var info ColInfo | ||
err := rows.Scan(&info.Name, &info.Type, &info.Comment) | ||
if err != nil { | ||
return nil, fmt.Errorf("failed to scan table: %w", err) | ||
} | ||
colInfos = append(colInfos, info) | ||
} | ||
return colInfos, nil | ||
} |
This file contains 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 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