Please try to define columns as DOUBLE, as the internal representation (e.g. in views) of floating point numbers is double. If the data should be exact (e.g. for comparisons), it is much better to use DECIMAL(X,Y). Note that FLOAT is an approximate numeric type and it is risky to use ‘=’ operator on it.
Here is what I am trying to do. I am confused why the last query for comparison does not work although I now use the decimal(x,y) to define the floating numbers in the table(iris), and subsequently the views defined for each decision class.
I’m confused too.
Could you, please, attach the script defining table and views, as well as the data itself? (I suppose this one is not confidential.) We will try to reproduce and debug the problem.
I have pasted the sql script for the table and views and also attached the iris data set. The script also contain the select statements which are returning empty sets. Thanks.
Thanks for test data. I have repeated your experiments but the join gives me 59 rows not an empty set. How do you load data? Can you give the exact statement?
I tried the following:
set @bh_dataformat = 'txt_variable'; LOAD DATA INFILE "iris.txt" INTO TABLE iris FIELDS TERMINATED BY ',' ENCLOSED BY 'NULL' LINES TERMINATED BY '\r\n';
I have loaded the data exactly same as yours. I upgraded the ICE to version 3.3.1 ( Please see below for starting the command line).
C:\Program Files (x86)\Infobright>“C:\Program Files (x86)\Infobright\bin\mysql.e
xe”—defaults-file=“C:\\Program Files (x86)\\Infobright\\my-ib.ini” -uroot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.1.40-log build number (revision)=IB_3.3.1_r6997_7018(ice)
I am very confused. Please let me know what is wrong that I do. I am using the same SQL what I posted but getting the count as Zero.
I managed to reproduce the problem. Indeed, there is a problem in resolving view name. The issue has been addressed and fixed some time ago and will be included in the next release (3.4.x) of ICE - 3.3.2 beta doesn’t have this fix. And as far as I know next release is planned soon, but I guess PM should give some more details.
As a workaround, I would suggest not using views but to expand their definition into main query. In this case that would be:
SELECT COUNT(*) FROM iris S, iris V WHERE S.sepal_length = V.sepal_length and S.decision_class = 'Iris-setosa' and V.decision_class = 'Iris-versicolor';
Thanks Piotr. You suggestion did help. However I am waiting for version 3.4 to be released soon. In the meantime, I have another question. Are stored procedures are possible to be created in Infobright. I am asking that because I want bunch of select statements to be run and then get the result. Thanks.
I was doing a test using the data set using the Heart_1.txt( that contains all the rows with decision class = 1, total records 150) and the Heart_2.txt ( that contains all the rows with decision class = 2, total records 120), both are attached below and did a simple query of join between these two tables on one attribute - Age and the results comes back with 506 rows which is more than the number of rows in the two tables together. I have attached the results(HeartResults.txt) and the select * from the two tables.
The result of join is correct. In general, a join is Cartesian product of rows from both tables. In your case, if there is no WHERE part, the result would contain 120x150=18000 rows. You added a condition that limited the result set to 506 rows. Nothing strange in it.
I am using the Sotred Procedure in the infobright and inside the stored procedure I am using a INNER JOIN in the following prepared statement
set @s = “select count(*) from iris_setosa inner join iris_versicolor using (?)”;
PREPARE stmt1 FROM @s;
I am getting an error when I run them:
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘?)’ at line 1