Unable to insert data into table after altering the table

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Unable to insert data into table after altering the table

radha
Hi,
 Insertion is failing, after altering the table.
 Followed below steps:

-> CREATE TABLE student (id_ VARCHAR, firstName VARCHAR, lastName VARCHAR,
birthDate TIMESTAMP, height DOUBLE, PRIMARY KEY(id))
-> INSERT INTO student (id, firstName, lastName, birthDate, height) VALUES
(1000, 'huxt', 'abx', CURRENT_TIMESTAMP(), 5.6);
-> ALTER TABLE student DROP COLUMN birthDate;
-> ALTER TABLE student ADD COLUMN birthDate VARCHAR;
-> INSERT INTO student (id, firstName, lastName, birthDate, height) VALUES
(1001, 'luan', 'qwst', '11223', 6.6);

Getting below error:
Error: class org.apache.ignite.binary.BinaryObjectException: Wrong value
has been set
[typeName=SQL_PUBLIC_STUDENT_e910ba3a_3a65_4d53_9265_8c12a9b0bac3,
fieldName=BIRTHDATE, fieldType=Timestamp, assignedValueType=String]
(state=50000,code=1)

Issues faced:
-> unable to insert the data after modifying the datatype of the field in a
table.
-> If i do " select * from student;" , I am seeing the old data being
inserted for the birthdate column, after dropping birthdate colmun and
adding the colmn with the same name but different datatype.

Is this a know issue? Or soemthing i am doing wrong.
If it is a know issue please provide the workaround.

Thanks
radha
Reply | Threaded
Open this post in threaded view
|

Re: Unable to insert data into table after altering the table

dmagda
Hi,

That's a known limitation caused by the fact that Ignite keeps metadata
even after a column is fully dropped. This to be addressed with the next
major release - Ignite 3.0.

As for now,


*When this happens _and you are still in development_, you need to go into
the*
*file system and remove the following directories: `marshaller/`, `db/`,
and `wal/`*
*located in the Ignite working directory (`db` and `wal` might be located
in other*
*places if you have redefined their location).*

*However, if you are _in production_ then instead of changing field types,
add a*
*new field named differently to your object model and remove the old one.
This operation is fully*
*supported. At the same time, the `ALTER TABLE` command can be used to add
new*

*columns or remove existing ones at run time. *

-
Denis


On Fri, Aug 2, 2019 at 1:46 PM radha jai <[hidden email]> wrote:

> Hi,
>  Insertion is failing, after altering the table.
>  Followed below steps:
>
> -> CREATE TABLE student (id_ VARCHAR, firstName VARCHAR, lastName VARCHAR,
> birthDate TIMESTAMP, height DOUBLE, PRIMARY KEY(id))
> -> INSERT INTO student (id, firstName, lastName, birthDate, height) VALUES
> (1000, 'huxt', 'abx', CURRENT_TIMESTAMP(), 5.6);
> -> ALTER TABLE student DROP COLUMN birthDate;
> -> ALTER TABLE student ADD COLUMN birthDate VARCHAR;
> -> INSERT INTO student (id, firstName, lastName, birthDate, height) VALUES
> (1001, 'luan', 'qwst', '11223', 6.6);
>
> Getting below error:
> Error: class org.apache.ignite.binary.BinaryObjectException: Wrong value
> has been set
> [typeName=SQL_PUBLIC_STUDENT_e910ba3a_3a65_4d53_9265_8c12a9b0bac3,
> fieldName=BIRTHDATE, fieldType=Timestamp, assignedValueType=String]
> (state=50000,code=1)
>
> Issues faced:
> -> unable to insert the data after modifying the datatype of the field in a
> table.
> -> If i do " select * from student;" , I am seeing the old data being
> inserted for the birthdate column, after dropping birthdate colmun and
> adding the colmn with the same name but different datatype.
>
> Is this a know issue? Or soemthing i am doing wrong.
> If it is a know issue please provide the workaround.
>
> Thanks
> radha
>