Skip to content
This repository has been archived by the owner on Jun 7, 2021. It is now read-only.

JIRA TRAFODION-2099 Add support for boolean datatype #590

Merged
merged 2 commits into from Jul 12, 2016

Conversation

anoopsharma00
Copy link
Contributor

-- boolean datatype support in create, cast and params
Ex:
create table t (a boolean);
insert into t values (true), (false);
select * from t where a = true;

-- boolean datatype support for hive columns

-- unarith op support. Currently used for '!' operator that
negates a boolean value.
Ex: select * from t where !a = false;

-- support for more tinyint and largeint unsigned conversion/comparison
operations in expressions and pcode

-- some code cleanup: removed reference to downrev compiler code genration

-- create table if not exists as select... syntax support

-- regress/seabase/TEST003 updated with additional tests

-- boolean datatype support in create, cast and params
  Ex:
   create table t (a boolean);
   insert into t values (true), (false);
   select * from t where a = true;

-- boolean datatype support for hive columns

-- unarith op support. Currently used for '!' operator that
   negates a boolean value.
   Ex: select * from t where !a = false;

-- support for more tinyint and largeint unsigned conversion/comparison
   operations in expressions and pcode

-- some code cleanup: removed reference to downrev compiler code genration

-- create table if not exists as select...   syntax support

-- regress/seabase/TEST003 updated with additional tests
@Traf-Jenkins
Copy link

Check Test Started: https://jenkins.esgyn.com/job/Check-PR-master/901/

@Traf-Jenkins
Copy link

@zellerh
Copy link
Contributor

zellerh commented Jul 11, 2016

Wow, this is a huge change. I didn't look at all the details, just at the big picture, and that looks good to me. Let me just ask a few questions, sorry, I should probably have answered those by myself by looking at the code:

We have these type classes, numerics, strings, datetime, interval. Where does boolean fit in here, is it treated as an exact numeric in internal methods? If so, some code has subclasses of numbers with binary and decimal precision, would this be another case that allows only two values? I'm partially thinking of UDFs, and how we should treat boolean values there.

As far as i can tell, this follows the ANSI definition of a boolean data type, is this true or are there differences?

Is this just experimental for now or should we add this type to the SQL Reference Manual?

Thanks, there are only a few people who can pull off a big change like this :-)

@@ -40,41 +40,107 @@

// ***********************************************************************
//
// SQLBoolean : The boolean data type
// SQLBooleanBase : The boolean data type
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A SQL version of the famous French stew. :-)

@DaveBirdsall
Copy link
Contributor

Looks good. All my comments are minor, except the one in str.cpp which I suspect is a genuine bug.

A general question: It looks like the only operations allowed on BOOLEAN columns are =, !=, and !. Are there plans to add support for AND and OR? Could I AND a BOOLEAN column with the result of a predicate?

@anoopsharma00
Copy link
Contributor Author

Response to Hans/Dave's comment regarding boolean datatype.

Boolean datatype is not a numeric datatype.
It cannot be used to compare or in arith opers with other numbers.
It is an additional datatype class to NUMERIC, CHARACTER, DATETIME, INTERVAL, BLOB.
Internally it is stored as a one byte value with 0 for false and 1 for true.

There is still some support for boolean needed in drivers and SPJ/UDF.
Once that is done, we can document it in manuals.

We could also enhance it later so relational and boolean datatype operations can be mixed.
Ex: update t set a = (b > 10)
or use boolean datatype in a predicate of the form: where a AND (b > 10);
(one can still use it as: where (a = true) AND (b > 10) );

@Traf-Jenkins
Copy link

New Check Test Started: https://jenkins.esgyn.com/job/Check-PR-master/909/

@DaveBirdsall
Copy link
Contributor

Looks good!

@Traf-Jenkins
Copy link

@asfgit asfgit merged commit 822c35e into apache:master Jul 12, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
5 participants