-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
25e9caa
commit 3280b64
Showing
6 changed files
with
114 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { | ||
ARRAY, | ||
DuckDBIntegerType, | ||
DuckDBType, | ||
DuckDBTypeId, | ||
LIST, | ||
MAP, | ||
STRUCT, | ||
UNION, | ||
} from '../../src'; | ||
|
||
export function replaceSqlNullWithInteger(input: DuckDBType): DuckDBType { | ||
switch (input.typeId) { | ||
case DuckDBTypeId.SQLNULL: | ||
return DuckDBIntegerType.create(input.alias); | ||
case DuckDBTypeId.LIST: | ||
return LIST(replaceSqlNullWithInteger(input.valueType), input.alias); | ||
case DuckDBTypeId.STRUCT: { | ||
const entries: Record<string, DuckDBType> = {}; | ||
for (let i = 0; i < input.entryCount; i++) { | ||
entries[input.entryNames[i]] = replaceSqlNullWithInteger( | ||
input.entryTypes[i] | ||
); | ||
} | ||
return STRUCT(entries, input.alias); | ||
} | ||
case DuckDBTypeId.ARRAY: | ||
return ARRAY( | ||
replaceSqlNullWithInteger(input.valueType), | ||
input.length, | ||
input.alias | ||
); | ||
case DuckDBTypeId.MAP: | ||
return MAP( | ||
replaceSqlNullWithInteger(input.keyType), | ||
replaceSqlNullWithInteger(input.valueType), | ||
input.alias | ||
); | ||
case DuckDBTypeId.UNION: { | ||
const members: Record<string, DuckDBType> = {}; | ||
for (let i = 0; i < input.memberCount; i++) { | ||
members[input.memberTags[i]] = replaceSqlNullWithInteger( | ||
input.memberTypes[i] | ||
); | ||
} | ||
return UNION(members, input.alias); | ||
} | ||
default: | ||
return input; | ||
} | ||
} |
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