- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2025 06:43 AM
Hi @DanielW
This is a common issue when connecting Power Apps to Databricks due to how data types are handled between the systems.
Here's how to resolve it:
When Databricks returns numeric types (int, bigint) through an API, they're being serialized as strings in the JSON response,
but your Power Apps connector expects them as numeric types according to your Swagger definition.
Solution
You need to adjust your Swagger definition to properly handle the type conversion. Try these approaches:
Option 1: Update your Swagger definition to expect strings
testint:
type: string
x-ms-powerApps-mapping:
powerAppsType: number
Option 2: Modify your Databricks API response
If you're writing a custom API endpoint in Databricks, ensure you're explicitly casting the numeric values:
# Example in Python
def get_data():
df = spark.sql("SELECT * FROM your_table")
# Convert numeric columns to actual numbers in the JSON
return df.toJSON().map(lambda x: json.loads(x)).collect()
Option 3: Create a transformation policy
In your custom connector, add a response transformation policy:
-- Go to your custom connector definition
-- Add a policy under "Response transformation"
-- Use a policy like:
in javascript:
#set($body = $response.body)
#foreach($item in $body.items)
#set($item.testint = $number.parseInt($item.testint))
#set($item.bigint = $number.parseInt($item.bigint))
#end
Best Practice Implementation
For the most reliable approach:
1. In your Swagger definition, define numeric columns as strings:
in yaml:
testint:
type: string
description: "Integer value (returned as string)"
2. In your Power App, use the Value() function to convert the string to a number when needed:
Value(YourDataSource.testint)
This approach handles the type mismatch by acknowledging that the values come as strings but can be
processed as numbers within Power Apps.