I used Vertex AI to create a time series forecasting model.
When performing Batch Prediction, the prediction results need to be uploaded to a BigQuery table.
In the BigQuery table, there is a column nameBenefit_per_order, which is of type FLOAT. However, MY model requires the input to be of type STRING.
Even if I tried changing all the values in the Benefit_per_order column to meaningless strings (e.g., "N/A"), the issue persists, and the prediction cannot proceed successfully.
The error message I encountered indicates a data type mismatch: the model requires the input to be of typeSTRING, but the column type in the BigQuery table remains FLOAT. Even if I modified the values in the column, the data type itself has not changed.
Hi @zhenyuzhuang,
Welcome to Google Cloud Community!
Even though you modified the values in the Benefit_per_order column, this will still not affect its data type.
Below are the possible solution to convert your column’s data type to string:
CREATE TABLE `mydataset.newtable` AS(
SELECT
field1,
field2,
CAST(Benefit_per_order AS STRING) as Benefit_per_order
FROM `mydataset.yourtable`)
Alternatively, you can create a materialized view using the CAST function instead of creating a table. Below is the sample query:
CREATE MATERIALIZED VIEW `mydataset.newtable` AS(
SELECT
field1,
field2,
CAST(Benefit_per_order AS STRING) as Benefit_per_order
FROM `mydataset.yourtable`)
To learn more about the materialized view, review this documentation.
3. Another approach to consider is using SET DATA TYPE DDL statements, but this approach is not suitable for your case since the only supported data type conversions are the following:
Was this helpful? If so, please accept this answer as “Solution”. If you need additional assistance, reply here within 2 business days and I’ll be happy to help.