How to take advantage of calcite-server - apache-calcite

Our project relies on calcite-core, but we also need to use DDL statements. The server module (calcite-server) adds DDL support to Calcite. How can we take advantage of calcite-server to support our demands?
calcite's documentations have mentioned that
If you are the author of a sub-project, it is unlikely that your syntax extensions match those in calcite-server, so we recommend that you add your SQL syntax extensions by extending the core parser; if you want DDL commands, you may be able to copy-paste from calcite-server into your project.
Does this mean that we should extend Calcite-core by ourselves instead of using Calcite-server directly.
Is there a better way?

If you are fine using the dialect of DDL supported by calcite-server, feel free. But if you have your own dialect of DDL, you'll likely need to write your own version of calcite-server.

Related

How to use Apache calcite LIKE_REGEX

I would like to use LIKE_REGEX in Apache calcite SQL query and can not find any documentation or examples on how to use it. Can you please share examples or documentation around it's usage.
LIKE_REGEX was introduced in the SQL:2008 standard but as of version 1.17 Calcite does not currently support it. (If you look at Calcite's SQL reference, LIKE_REGEX appears in Calcite's list of reserved SQL keywords because Calcite automatically reserves keywords listed in the SQL standard.)
If you would like to match regular expressions, use SIMILAR TO. For example, the query VALUES 'abcccd' similar to 'ab*c+d' returns TRUE.
Calcite's implementation of SIMILAR TO has semantics similar to PostgreSQL's implementation.

C++ Code Naming Style Converter, Formatter or Beautifier

I am looking for a good tool that can automatically convert c++ naming styles, such as change method name from "SetPosition()" to "setPosition()", and class name "CPoint" to "Point". Seems most of formatters have no such feature. Thanks.
You can manipulate C++ source using Clang, although you might have to write a bit of code to do the conversion that you have in mind.
For example, the Clang infrastructure would allow you to write a program that iterates over all class method names in a given source file. You could then programatically convert any pascal-case method names that you encounter into camel-case names.
Code formatters don't do renaming of functions. What you need is a refactoring tool that can perform rename. If your project isn't very big then Devexpress Refactor! for C++ (free) might be of help. It will involve some manual work, but it'll be safer than search and replace. Qt Creator has a rename reporting built in an I have found it to be quite reliable (hasn't messed up so far unlike some dedicated refactoring tools).
If manual work using refactoring tools is too much then you can use clangs pieces to build a tool that performs the refactorings automatically, but this is probably more work than the semi-manual process with refactoring tools.

Are there any Oracle Stored Procedure Accessor Generators for C++?

I've been spending more and more time writing DB Wrappers for Oracle access. This seems to be quite generic procedure, and I was wondering is there already are code generators that generate access routes to Oracle PL/SQL Stored Procedures in C++?
I'm looking for a configurable generation tool that would be capable of managing connection and handle multiple threads if needed. I'm aware of OCI/OCCI and Oracle C++ extension, but I'm looking for a pure self-contained C++ accessor generation tool.
Any advice welcome.
Thank You!
You might also want to have a look at:
http://orclib.sourceforge.net
http://otl.sourceforge.net/
http://www.codeguru.com/cpp/data/mfc_database/oracle/article.php/c4305
We use the SQLAPI (http://www.sqlapi.com/) for all of our C++ development w/ Oracle. It I think is a more efficient wrapper for the OCI (though as another person pointed out, the OCCI is prety good). Another advantage for the SQLAPI is that it also supports other database platforms. We use it for MySQL as well and having that abstraction layer in between our application and database layers certainly simplifies things quite a bit.

Embedded scripting engine for DSL

I'm working on a project which needs an embedded DSL to fullfill its expected requirements.
The DSL would be user defined event based. Here goes a mockup of the desired syntax:
user-defined-event-1 {
// event body
}
user-defined-event-2 {
// event body
}
Probably, most similar language I know based on events is LSL (from Second Life).
So, after reading other similar questions on SO, I would like to ask for the best embeddable scripting engine (Ruby, Lua, Python, etc) on C++ (I work in Qt) which allows me to create this DSL.
In my project, I would test that the script properly uses the DSL syntax (at least one event defined) and give the user all the power of the underlying scripting engine and, if possible, Qt.
It is not a requirement for the embedded language to work with Qt. It can be isolated, but it would be nice to have some integration too.
There's at least a few Qt-Lua bindings out there. Lua can somewhat do the syntax you've shown above; specifically, {} indicates a table (associative array) in Lua, and if you are only passing an anonymous table to a function, you don't need parentheses:
Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio
> function LengthOfTable(t) print(#t) end
> LengthOfTable ({"a","b","c"})
3
> LengthOfTable {"a","b","c"}
3
Whether Lua is actually the best for your application, depends on your application, of course. Either way, Lua is very easy (IMO) to embed in C or C++.
You could look at embeddable javascript, through Google's V8 project, which is written in C++.
http://code.google.com/apis/v8/intro.html
Qt comes with the QtScript scripting module. It uses an ECMAScript based langauge (like javascript).
Tcl comes fairly close to your proposed syntax:
proc user-defined-event-1 {} {
# event body
puts "Hello World"
}
proc defines a procedure, and the extra {} braces are used for arguments. In a tcl shell, procedures can be dynamically typed in line-by-line, copied and pasted, or loaded from a file. They can also be redefined by simply reloading them.
I've never tried it but there is PyQt.
I believe boost::python is pretty easy to implement. I hear there are some python-Qt solutions too.
You seem to have very specific requirements for picking a generic DSL. You may want to try a generic DSL library (e.g. Boost.Proto) rather than a prexisting-embedded language.
For embedding a DSL within your app, I recommend ANTLR. I have used ANTLR over the years, the latest being within a JDBC driver for Cassandra. You might want to try version 4 which has a C++ runtime. Version 3 was problematic with Qt over a collision with the keyword emit.

ColdFusion code parser?

I'm trying to create an app to search my company's ColdFusion codebase. I'd like to be able to do intelligent searches, for example: find where a function is defined (and not hit everywhere the function is called). In order to do this, I'd need to parse the ColdFusion code to identify things like function declarations, function calls, database queries, etc.
I've looked into using lex and yacc, but I've never used them before and the learning curve seems very steep. I'm hoping there is something already out there that I could use. My other option is a mess of difficult-to-maintain regex-spaghetti code, which I want to avoid.
I used the source to CFEclipse, since it is open source and has a parser. Not sure about the legality of this if we were selling/redistributing it, but we're only using it for an internal tool.
Writing parsers for real langauges is usually difficult because they contain constructs that Lex and Yacc often don't handle well, e.g., the langauge isn't LALR(1). ColdFusion might be easier than some because of its XML-like style.
If you want to build a sophisticated parser quickly, you might consider using our
DMS Software Reengineering Toolkit which has GLR parsing support.
If you want to avoid writing your own or hacking all those Regexps, you could consider our Source Code Search Engine. It has language-sensitive parsers and can search across very large source code bases very quickly. One of its "language sensitive" parsers is AdhocText, which is designed to handle "generic" programming languages such as those you might find in a random programming book; it even understands XML-like tags such as ColdFusion has. You can download a evaluation version from the link provided to try it.
EDIT 4/3/2010: A recent feature added to the SCSE is the ability to tag definitions and uses separately. That would address the OP's desire to find the function definition rather than all the calls.
None existed. Since ColdFusion is more like scripts than code, I'd imagine it'll be hard to write a parser for it.
ColdFusion Builder can parse CFM/CFC to an outline in Eclipse. Maybe you can do some research on whether a CF Builder plugin can do what you want to do.