Hi Charles,
So it is actually supported. Drill's boolean vector is BitVector.
Internally bits are stored efficiently, but when you fetch a bit from the
vector it becomes an int, -1 for true and 0 for false. So currently you can
check this by using singletonInt and comparing against -1 and 0.
Here is a test snippet that does it. We should probably add some
convenience methods specifically for booleans so this is not so confusing.
public class SimpleQueryTest extends ClusterTest {
@Rule
public final BaseDirTestWatcher baseDirTestWatcher = new BaseDirTestWatcher();
@Before
public void start() throws Exception {
startCluster(new ClusterFixtureBuilder(baseDirTestWatcher));
}
@Test
public void testBoolean() throws RpcException {
RowSet rowSet = this.queryBuilder().sql("select position_id,
cast(false as boolean) from cp.`employee.json`").rowSet();
RowSetReader reader = rowSet.reader();
reader.next();
System.out.println(reader.column(1).scalar().getInt());
rowSet.clear();
rowSet = this.queryBuilder().sql("select position_id, cast(true as
boolean) from cp.`employee.json`").rowSet();
reader = rowSet.reader();
reader.next();
System.out.println(reader.column(1).scalar().getInt());
rowSet.clear();
}
}
On Thu, Jun 28, 2018 at 4:09 PM, Timothy Farkas <[email protected]> wrote:
> Hi Charles,
>
> Currently the RowSetReader doesn't support booleans, but it can be added.
> I'll try to add it now, and see if it could be done quickly. I'll update
> you on my progress.
>
> Tim
>
> On Thu, Jun 28, 2018 at 2:38 PM, Charles Givre <[email protected]> wrote:
>
>> Hi Tim,
>> Could post some sample code as to how to test a SQL query that returns a
>> Boolean?
>> —C
>>
>> > On Jun 28, 2018, at 17:30, Timothy Farkas <[email protected]> wrote:
>> >
>> > - We would have to add a boolean column reader to ColumnAccessors and
>> wire
>> > it in and add a getBoolean method to ScalarReader.
>> >
>> > - Your example should work as is, ClusterTest has a testBuilder method
>> > that allows you to use the traditional test builder. Is there something
>> not
>> > working with the test builder?
>> >
>> > Tim
>> >
>> >
>> > On Thu, Jun 28, 2018 at 12:39 PM, Arina Yelchiyeva <
>> > [email protected]> wrote:
>> >
>> >> Hi Tim,
>> >>
>> >> it looks like deprecating BaseTestQuery was a little bit pre-mature.
>> >> For example, from in this PR - https://urldefense.proofpoint.
>> com/v2/url?u=https-3A__urldefense.proofpoint&d=DwIFaQ&c=cskd
>> kSMqhcnjZxdQVpwTXg&r=4eQVr8zB8ZBff-yxTimdOQ&m=D9i95wxPKk0aPH
>> ip2Rj6Xju0J151UakaSe6OnMGTW5s&s=z5tYyOUI_Cyx1cwhMEMfnCb-
>> BDFaZkRaKQKwt_zl2HA&e=.
>> >> com/v2/url?u=https-3A__github.com_apache_drill_pull_1331&d=DwIBaQ&c=
>> >> cskdkSMqhcnjZxdQVpwTXg&r=4eQVr8zB8ZBff-yxTimdOQ&m=
>> >> zoNJPdWKxMX9-jbR2bftzwkX-CSrihIbpCirhHM1kA0&s=_uxhA_
>> >> qiMBTjbit6DDw-DvZNRGesfeA5g-FQjkl7f10&e= -
>> >> Charles is trying to re-work BaseTestQuery usage to ClusterTest.
>> >> First, it did not contain getSigletonDouble method which Charles has
>> >> implemented. Now he has troubles with implementing getSigletonBoolean
>> >> method which might be due to reader limitations.
>> >> Also I am not quite clear how we can verify columns names and multiple
>> >> columns in the result.
>> >> For example:
>> >>
>> >> testBuilder()
>> >> .sqlQuery("select (mi || lname) as CONCATOperator, mi, lname,
>> >> concat(mi, lname) as CONCAT from concatNull")
>> >> .ordered()
>> >> .baselineColumns("CONCATOperator", "mi", "lname", "CONCAT")
>> >> .baselineValues("A.Nowmer", "A.", "Nowmer", "A.Nowmer")
>> >> .baselineValues("I.Whelply", "I.", "Whelply", "I.Whelply")
>> >> .baselineValues(null, null, "Derry", "Derry")
>> >> .baselineValues("J.Spence", "J.", "Spence", "J.Spence")
>> >> .build().run();
>> >>
>> >> Can you please suggest how this example can be re-written?
>> >>
>> >> Kind regards,
>> >> Arina
>> >>
>> >> On Mon, Jun 25, 2018 at 11:10 PM Timothy Farkas <[email protected]>
>> wrote:
>> >>
>> >>> Hi All,
>> >>>
>> >>> BaseTestQuery was deprecated a while ago. Keeping it short and sweet
>> :),
>> >> if
>> >>> you want to use BaseTestQuery directly, don't. Use ClusterTest
>> instead.
>> >> If
>> >>> you are using PlanTestBase for planner tests, continue to do so.
>> >> Eventually
>> >>> PlanTestBase will be changed to extend ClusterTest instead. There is a
>> >> JIRA
>> >>> to track that issue https://urldefense.proofpoint.
>> com/v2/url?u=https-3A__urldefense.proofpoint&d=DwIFaQ&c=cskd
>> kSMqhcnjZxdQVpwTXg&r=4eQVr8zB8ZBff-yxTimdOQ&m=D9i95wxPKk0aPH
>> ip2Rj6Xju0J151UakaSe6OnMGTW5s&s=z5tYyOUI_Cyx1cwhMEMfnCb-
>> BDFaZkRaKQKwt_zl2HA&e=.
>> >> com/v2/url?u=https-3A__issues.apache.org_jira_browse_DRILL-
>> >> 2D6536&d=DwIBaQ&c=cskdkSMqhcnjZxdQVpwTXg&r=4eQVr8zB8ZBff-yxTimdOQ&m=
>> >> zoNJPdWKxMX9-jbR2bftzwkX-CSrihIbpCirhHM1kA0&s=
>> >> BPAlenAq0k1kjAz7fUYXyEQMaJM1IPOgmdeySMMY84U&e=.
>> >>>
>> >>> Thanks,
>> >>> Tim
>> >>>
>> >>
>>
>>
>