简体   繁体   中英

The data type of java.lang.String object [] does not correspond to value meta [Date]

Using Pentaho with Python Plugin, I have an incoming CSV which has two fields, Month and Year , that I need to create a Date out of. Month contains full month names, eg, "January", "February", etc.

To do this, I create pandas script ("create date"), then add Day field and set to 1, then get the month numbers from Month , then create date_tw field and create the datetime from Year , Month , Day .

create date outputs all fields, and the new date_tw field as Date type.

在此处输入图片说明

One of the field outputs from python script:

在此处输入图片说明

Data Output creates a table and date_tw is of Date type.


So far we have: newly created date_tw from python, which is fed to Data Output , which has already created the table with date_tw also as Date type. Both are Date types.

Yet I get this error:

date_tw Date : There was a data type error: the data type of java.lang.String object [06/01/2017] does not correspond to value meta [Date]

It looks like I should turn off "Lazy Conversion" at the CSV file input step. This was also done.

Pandas script in Pentaho:

import pandas as pd
import calendar as cal

df['Day'] = 1
mapping = {v : k for k, v in enumerate(cal.month_name)}
df['Month'] = df['Month'].map(mapping) 
df['date_tw'] = ''
df['date_tw'] = pd.to_datetime(df[['Year', 'Month', 'Day']], format='%Y/%m/%d')
df['date_tw'] = df['date_tw'].dt.strftime('%m/%d/%Y')

result_df = df

Postgresql table field:

在此处输入图片说明

Data types match and lazy conversion is off. What am I missing?

Pentaho metadata contains the date format for each object of type Date. And the date_tw of the Python script seams to be in the format dd/mm/yyyy.

You can check the type and format of any field with a right click on the Python script and select Output fields... . Check if it is dd/mm/yyyy nd not your locale.

If it is not and if the Python script does not let you specify the date format, do it with the strftime on the last but one line.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM