apache / apache/datafusion-sqlparser-rs

parse error with in-column-select-statement

Aberta
#273 3 comentários 0 reações 0 responsáveis Ver no GitHub
question
Linguagem predominante
Rust
Estrelas
3.5k
Forks
772
Merge médio
4d 9h
PRs com merge (30d)
17

Descrição

This mssqlserver view can't be parsed

the issue could be related to the in-column-statement, which for example is used at
- InheritDescriptions_actual
- PK_json

```sql
CREATE VIEW [integration].[Schema_Table] AS
SELECT
[Schema_Name] = [T2].[Schema_Name],
[Table_Name] = [T1].[Table_Name],
[AnonStatement] = [T1].[AnonStatement],
[CompressionTypeID] = [T1].[CompressionTypeID],
[Description] = [T1].[Description],
[DoNotExport] = [T1].[DoNotExport],
[DontInheritPK] = [T1].[DontInheritPK],
[FriendlyName] = [T1].[FriendlyName],
[Hashkey] = [T1].[Hashkey],
[HistOfTableID] = [T1].[HistOfTableID],
[HubOfTableID] = [T1].[HubOfTableID],
[InheritDescriptions] = [T1].[InheritDescriptions],
[InheritDescriptions_actual] = ISNULL([T1].[InheritDescriptions], -- Parameter_Name must exist in INTERN.PARAMETERS:
--(SELECT ParameterValue = COALESCE(PV.Param_Value, P.Default_Value, '') FROM INTERN.PARAMETERS P (NOLOCK) LEFT JOIN [CFG].[PARAM_VALUES] PV (NOLOCK) ON PV.Param_Name = P.Param_Name WHERE P.Param_Name = 'DESCRIPTION_INHERIT_TABLES')
--this works also for Custom-Parmeters, existing only in [CFG].[PARAM_VALUES]:
(SELECT ParameterValue = COALESCE(PV.Param_Value, P.Default_Value, '') FROM (SELECT Param_Name FROM INTERN.PARAMETERS (NOLOCK) UNION SELECT Param_Name FROM INTERN.PARAMETERS (NOLOCK)) AS U LEFT JOIN INTERN.PARAMETERS P (NOLOCK) ON P.Param_Name = U.Param_Name LEFT JOIN [CFG].[PARAM_VALUES] PV (NOLOCK) ON PV.Param_Name = U.Param_Name WHERE P.Param_Name = 'DESCRIPTION_INHERIT_TABLES')
),
[InheritFriendlyNames] = [T1].[InheritFriendlyNames],
[InheritFriendlyNames_actual] = ISNULL([T1].[InheritFriendlyNames], -- Parameter_Name must exist in INTERN.PARAMETERS:
--(SELECT ParameterValue = COALESCE(PV.Param_Value, P.Default_Value, '') FROM INTERN.PARAMETERS P (NOLOCK) LEFT JOIN [CFG].[PARAM_VALUES] PV (NOLOCK) ON PV.Param_Name = P.Param_Name WHERE P.Param_Name = 'FRIENDLYNAME_INHERIT_TABLES')
--this works also for Custom-Parmeters, existing only in [CFG].[PARAM_VALUES]:
(SELECT ParameterValue = COALESCE(PV.Param_Value, P.Default_Value, '') FROM (SELECT Param_Name FROM INTERN.PARAMETERS (NOLOCK) UNION SELECT Param_Name FROM INTERN.PARAMETERS (NOLOCK)) AS U LEFT JOIN INTERN.PARAMETERS P (NOLOCK) ON P.Param_Name = U.Param_Name LEFT JOIN [CFG].[PARAM_VALUES] PV (NOLOCK) ON PV.Param_Name = U.Param_Name WHERE P.Param_Name = 'FRIENDLYNAME_INHERIT_TABLES')
),
[InheritReferences] = [T1].[InheritReferences],
[IsInMemory] = [T1].[IsInMemory],
[LinkOfTableID] = [T1].[LinkOfTableID],
[OLAP_DataCategory] = [T1].[OLAP_DataCategory],
[OLAP_IsHidden] = [T1].[OLAP_IsHidden],
[PersistOfTableID] = [T1].[PersistOfTableID],
[Perspective] = [T1].[Perspective],
[SatOfTableID] = [T1].[SatOfTableID],
[SchemaID] = [T1].[SchemaID],
[SchemaName_TableName] = CONCAT(T2.Schema_Name, '.', [T1].[Table_Name]),
[SchemaName_TableName_brackets] = CONCAT('[', T2.Schema_Name, '].[', [T1].[Table_Name], ']'),
[TableID] = [T1].[TableID],
[TableType_Name] = [T3].[Type_Name],
[TableTypeID] = [T1].[TableTypeID],
[PK_json] = --sorted list of PK:
(
SELECT
[PK_Ordinal_Position] AS PK
, [Column_Name] AS C
FROM
[CFG].[COLUMNS] AS cfgc
WHERE
[T1].[TableID] = cfgc.[TableID]
AND NOT [PK_Ordinal_Position] IS NULL
ORDER BY [PK_Ordinal_Position]
FOR JSON AUTO
)
FROM
[CFG].[TABLES] T1 (NOLOCK)
LEFT JOIN [CFG].[SCHEMAS] T2 (NOLOCK) ON
T2.[SchemaID] = T1.[SchemaID]
LEFT JOIN [INTERN].[TABLE_TYPES] T3 (NOLOCK) ON
T3.[TableTypeID] = T1.[TableTypeID]
WHERE
1 = 1
```

Guia de contribuição

Nenhum guia de contribuição indexado para este repositório

Direção de pesquisa

Comece reproduzindo a view MSSQL fornecida, concentrando-se nas subconsultas escalares dentro das colunas e na expressão PK_json usando ORDER BY e FOR JSON AUTO. Rastreie como esse SQL é analisado e adicione cobertura para o exemplo; considera-se concluído quando a view é analisada com sucesso sem causar regressões na sintaxe MSSQL relacionada.

Escrita pelo modelo de indexação a partir do texto da issue.

Avaliação

Stack de tecnologia
rust, sql
Domínio
compilers, databases
Tipo de issue
Bug
Dificuldade
4/5
Tempo estimado
3-5 dias
Status de atividade
Estagnada
Clareza
Precisa de esclarecimento
Facilidade para iniciantes
25/100

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.