[MCOL-360] Internal error: Un-recognized Arithmetic Operand during query with timestamp Created: 2016-10-14  Updated: 2016-12-15  Resolved: 2016-12-15

Status: Closed
Project: MariaDB ColumnStore
Component/s: MariaDB Server
Affects Version/s: 1.0.3
Fix Version/s: Icebox

Type: Bug Priority: Major
Reporter: Kumar Saurav Sonu Assignee: Andrew Hutchings (Inactive)
Resolution: Won't Fix Votes: 0
Labels: community

Sprint: 2016-22, 2016-24

 Description   

Steps to reproduce :-
1)Create a table -> table_1
CREATE TABLE `table_1` (
`id` int(11) NOT NULL,
`time_slice_size` int(11) DEFAULT NULL
) ENGINE=Columnstore DEFAULT CHARSET=latin1;

2)Insert data in table_1 -> insert into table_1 values(1,60);

3)Create another table -> table_2
CREATE TABLE `table_2` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`start_timestamp` timestamp NULL DEFAULT NULL,
`end_timestamp` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=9155 DEFAULT CHARSET=latin1;

4)Insert data into table_2 :- insert into table_2 values (1,'2016-10-10 08:00:00','2016-10-10 09:00:00');

5)Run below query :-
select tb1.time_slice_size,tb2.id bm_id, tb2.end_timestamp, tb2.start_timestamp FROM table_1 tb1, table_2 tb2 where tb1.id = tb2.id AND '1970-01-01 06:30:00' >= from_unixtime((unix_timestamp(tb2.end_timestamp)-unix_timestamp(tb2.start_timestamp))%tb1.time_slice_size) limit 1;

This will give ERROR 1815 (HY000): Internal error: Un-recognized Arithmetic Operand.

And if i replace tb1.time_slice_size with some hard coded values like 60.It work fine.

select tb1.time_slice_size,tb2.id bm_id, tb2.end_timestamp, tb2.start_timestamp FROM table_1 tb1, table_2 tb2 where tb1.id = tb2.id AND '1970-01-01 06:30:00' >= from_unixtime((unix_timestamp(tb2.end_timestamp)-unix_timestamp(tb2.start_timestamp))%60);



 Comments   
Comment by David Thompson (Inactive) [ 2016-10-18 ]

The query also works if you use tb2.id so that the column value is coming from the myisam table. Would seem to be a bug / limitation in cross engine queries.

Comment by David Thompson (Inactive) [ 2016-11-29 ]

The original query also works if you make table_2 a columnstore table.

It's possible that this query is considered spaghetti by the engine because you have a query that needs to be evaluated on a non cs table that needs the cs table values to compute. Cross engine joins are more designed for star schema type joins where a smaller result set is used to hashjoin a larger table.

Comment by Andrew Hutchings (Inactive) [ 2016-12-15 ]

When a MyISAM table has 0 or 1 rows in it the MariaDB optimizer does a shortcut called "system" in the explain plan. This is a condition which is not pushed down to ColumnStore (and neither is the table itself) so it sees the LHS of the '%' operand in the query as empty triggering the error.
There is no good fix for this. But several good workarounds:

1. Add another row in the MyISAM table. As long as there are 2 or more rows it will be fine

2. Use InnoDB. I'd recommend this anyway. There are many reasons why joining to MyISAM is probably not a good idea.

I'll document this in the KB and then close as won't fix.

Comment by Andrew Hutchings (Inactive) [ 2016-12-15 ]

Documented in the notes section:
https://mariadb.com/kb/en/mariadb/configuring-columnstore-cross-engine-joins/

Generated at Thu Feb 08 02:20:28 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.