Open ashutran opened 1 month ago
Here are the code search results. I'm now analyzing these search results to write the PR.
dbt_core_integration.py
Add debugging statements to the `_compile_node` method to log the progress of the incremental logic macro execution.
---
+++
@@ -13,6 +13,21 @@
else:
# this is essentially a convenient wrapper to adapter.get_compiler
compiled_node = self.sql_compiler.compile(self.dbt)
+
+ # Add debugging statements
+ self.dbtTerminal.debug(
+ "_compile_node",
+ f"Compiling node: {node.unique_id}",
+ )
+ self.dbtTerminal.debug(
+ "_compile_node",
+ f"Raw SQL: {getattr(compiled_node, RAW_CODE)}",
+ )
+ self.dbtTerminal.debug(
+ "_compile_node",
+ f"Compiled SQL: {getattr(compiled_node, COMPILED_CODE)}",
+ )
+
return DbtAdapterCompilationResult(
getattr(compiled_node, RAW_CODE),
getattr(compiled_node, COMPILED_CODE),
dbt_core_integration.py
Verify that the `sql_compiler` is properly set up and configured to handle macros with if-else statements.
---
+++
@@ -7,4 +7,13 @@
self._sql_compiler = SqlCompileRunner(
self.config, self.adapter, node=None, node_index=1, num_nodes=1
)
+
+ # Verify sql_compiler configuration
+ assert self._sql_compiler.config.has_option("compile", "handle_macros"), (
+ "sql_compiler configuration missing 'handle_macros' option"
+ )
+ assert self._sql_compiler.config.get("compile", "handle_macros"), (
+ "sql_compiler not configured to handle macros"
+ )
+
return self._sql_compiler
dbt_core_integration.py
Ensure that the `compile` method of the `sql_compiler` is being called with the correct arguments, including the dbt manifest.
---
+++
@@ -12,7 +12,7 @@
)
else:
# this is essentially a convenient wrapper to adapter.get_compiler
- compiled_node = self.sql_compiler.compile(self.dbt)
+ compiled_node = self.sql_compiler.compile(manifest=self.dbt)
return DbtAdapterCompilationResult(
getattr(compiled_node, RAW_CODE),
getattr(compiled_node, COMPILED_CODE),
dbt_core_integration.py
Add logging statements in the `_compile_node` method to capture the compiled code generated by dbt and the plugin.
---
+++
@@ -13,10 +13,25 @@
else:
# this is essentially a convenient wrapper to adapter.get_compiler
compiled_node = self.sql_compiler.compile(self.dbt)
- return DbtAdapterCompilationResult(
+
+ # Log compiled code
+ self.dbtTerminal.debug(
+ "_compile_node",
+ f"DBT compiled code: {getattr(compiled_node, COMPILED_CODE)}",
+ )
+
+ result = DbtAdapterCompilationResult(
getattr(compiled_node, RAW_CODE),
getattr(compiled_node, COMPILED_CODE),
compiled_node,
)
+
+ # Log plugin compiled code
+ self.dbtTerminal.debug(
+ "_compile_node",
+ f"Plugin compiled code: {result.compiled_sql}",
+ )
+
+ return result
except Exception as e:
raise Exception(str(e))
Your changes have been successfully made to the branch sweep/incorrect_compile_code_from_dbt_power_us
. I have validated these changes using a syntax checker and a linter.
[!TIP] To recreate the pull request, edit the issue title or description.
This is an automated message generated by Sweep AI.
Expected behavior
While using the Complied DBT preview feature result is not as expected:
{ "code": -1, "message": "Database Error\n Syntax error: SELECT list must not be empty at [305:1]", "data": "\"Error: Database Error\n Syntax error: SELECT list must not be empty at [305:1]\n\tat DBTCoreProjectIntegration_1. (c:\\Users\\.vscode\\extensions\\innoverio.vscode-dbt-power-user-0.39.12\\dist\\extension.js:18398:127)\n\tat Generator.throw ()\n\tat rejected (c:\\Users\\.vscode\\extensions\\innoverio.vscode-dbt-power-user-0.39.12\\dist\\extension.js:25808:28)\""
}
![2024-05-22 12_38_24-](https://github.com/AltimateAI/vscode-dbt-power-user/assets/40270276/b8a8d161-845f-42b8-ac34-f2bbff9bea45)
Actual behavior
After compiling the code
Steps To Reproduce
Using poetry shell to activate the poetry virtual env Using python version 3.11.6 dbt-core 1.6.1 dbt-bigquery 1.6.4
Create any model having Macro for incremental logic using if-else where it'll check if the table exist then if condition else another condition
![image](https://github.com/AltimateAI/vscode-dbt-power-user/assets/40270276/3d6791f3-5145-46f3-abf9-32741c5be90d)
Log output/Screenshots
No response
Operating System
Windows 10
dbt version
1.6.1
dbt Adapter
dbt-bigquery 1.6.4
dbt Power User version
v0.39.12
Are you willing to submit PR?