我需要在select语句中显示表名.怎么样?
确切的问题:
我们在两个表中有共同的列.我们正在使用显示记录
select column_name from table_name_1
union
select column_name from table_name_2
Run Code Online (Sandbox Code Playgroud)
但要求是,我们需要显示源table_name和数据.考虑a,c存在于table_1和b中,d存在于table_2中.
我们需要以下列方式输出
例如:
column_name table_name
a table_1
b table_2
c table_1
d table_2
.......................................................
......................................................
Run Code Online (Sandbox Code Playgroud)
这可能吗
古怪
我已经编译了Google协议缓冲区,没有使用额外的参数进行"膨胀"编译,并使用以下命令进行编译./configure CXXFLAGS="-ffunction-sections -fdata-sections"
.du-h透露:
120K ./bloat/bin
124K ./bloat/include/google/protobuf/io
8.0K ./bloat/include/google/protobuf/compiler/java
12K ./bloat/include/google/protobuf/compiler/python
8.0K ./bloat/include/google/protobuf/compiler/cpp
128K ./bloat/include/google/protobuf/compiler
52K ./bloat/include/google/protobuf/stubs
848K ./bloat/include/google/protobuf
852K ./bloat/include/google
856K ./bloat/include
12K ./bloat/lib/pkgconfig
37M ./bloat/lib
38M ./bloat
20K ./unbloat/bin
124K ./unbloat/include/google/protobuf/io
8.0K ./unbloat/include/google/protobuf/compiler/java
12K ./unbloat/include/google/protobuf/compiler/python
8.0K ./unbloat/include/google/protobuf/compiler/cpp
128K ./unbloat/include/google/protobuf/compiler
52K ./unbloat/include/google/protobuf/stubs
848K ./unbloat/include/google/protobuf
852K ./unbloat/include/google
856K ./unbloat/include
12K ./unbloat/lib/pkgconfig
15M ./unbloat/lib
16M ./unbloat
53M .
Run Code Online (Sandbox Code Playgroud)
深入研究:
ls -gGh bloat/lib/
total 37M
-rw-r--r-- 1 13M 2010-09-07 13:57 libprotobuf.a
-rwxr-xr-x 1 986 2010-09-07 13:57 libprotobuf.la
-rw-r--r-- 1 …
Run Code Online (Sandbox Code Playgroud) 我正在使用date_time来抽象出平台的特殊性.我需要生成一个64位的microsec分辨率uint64_t,它将用于序列化.我不明白下面出了什么问题.
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/cstdint.hpp>
#include <iostream>
using namespace boost::posix_time;
using boost::uint64_t;
ptime UNIX_EPOCH(boost::gregorian::date(1970,1,1));
int main() {
ptime current_time = microsec_clock::universal_time();
std::cout << "original time: "<< current_time << std::endl;
long microsec_since_epoch = ((current_time -UNIX_EPOCH).total_microseconds());
ptime output_ptime = UNIX_EPOCH + microseconds(microsec_since_epoch);
std::cout << "Deserialized time : " << output_ptime << std::endl;
std::cout << "Microsecond output: " << microsec_since_epoch << std::endl;
std::cout << "Microsecond to second arithmetic: "
<< microsec_since_epoch/(10*10*10*10*10*10) << std::endl;
std::cout << "Microsecond to tiume_duration, back to microsecond : " …
Run Code Online (Sandbox Code Playgroud) 在Lua的说法中,是否有任何语法糖用于将迭代器函数转换为数组(重复调用结果存储在升序索引中),也许是标准库中的某些内容?
我正在对属于协议的字符串进行标记,并且需要对字符串开头的元素进行位置访问,并且字符串的结尾是变量集合.
代码(特定于我的用例)如下,我发现很难相信它不在标准库中:d
local array_tokenise = function (line)
local i = 1;
local array = {};
for item in string.gmatch(line,"%w+") do
array[i] = item;
i = i +1
end
return array
end
Run Code Online (Sandbox Code Playgroud) 我有一个候选键(mongodb候选键,__ id)在协议缓冲区中看起来如下:
message qrs_signature
{
required uint32 region_id = 1;
repeated fixed32 urls = 2;
};
Run Code Online (Sandbox Code Playgroud)
当然,我不能ParseToString(std::string)
在我的bson文档中使用协议缓冲区编码的字符串(via ),因为它可以包含非打印字符.因此,我使用ascii85编码来编码数据(使用此库).我有两个问题.
编辑
该append binary
API的节目的数据被编码为十六进制(OMG!),base85因此更节省空间(每个记录22个字节在我的情况).
我有一个在postgres UDF中生成的查询字符串,我想将它的结果放在临时表中以执行连接(我正在使用LIMIT
和OFFSET
,并且我不想加入其他ttables只是为了结束choping最后关闭的数据 - 查询计划中的LIMIT运算符).我尝试使用以下语句创建临时表.
CREATE LOCAL TEMP TABLE query_result ON COMMIT DROP AS EXECUTE query_string_;
Run Code Online (Sandbox Code Playgroud)
但我收到以下错误通知:
********** Error **********
ERROR: prepared statement "query_string_" does not exist
SQL state: 26000
Context: SQL statement "CREATE LOCAL TEMP TABLE query_result ON COMMIT DROP AS EXECUTE query_string_"
PL/pgSQL function "search_posts_unjoined" line 48 at SQL statement
Run Code Online (Sandbox Code Playgroud)
另外,我试过准备政治家,但我也无法正确使用语法.
有问题的UDF是:
CREATE OR REPLACE FUNCTION search_posts_unjoined(
forum_id_ INTEGER,
query_ CHARACTER VARYING,
offset_ INTEGER DEFAULT NULL,
limit_ INTEGER DEFAULT NULL,
from_date_ TIMESTAMP WITHOUT TIME ZONE …
Run Code Online (Sandbox Code Playgroud) 编辑:我已经删除了词法分析器,因为它没有与Qi完全集成,只是混淆了语法(见这里).
on_success
没有很好的文档记录,我正在尝试将其连接到我的解析器.on_success
处理解析器的例子只是构建在qi
--ie,no lex
.
这就是我试图介绍构造的方式:
using namespace qi::labels;
qi::on_success(event_entry_,std::cout << _val << _1);
Run Code Online (Sandbox Code Playgroud)
但它不会编译.我担心这个问题lex
.有人可以告诉我我做错了什么,然后告诉我所有占位符可用,类型和它们代表什么(因为它们没有记录).
完整文件如下:
#include <boost/spirit/include/phoenix_core.hpp>
#include <boost/spirit/home/phoenix/bind/bind_member_variable.hpp>
#include <boost/spirit/include/lex_lexertl.hpp>
#include <boost/spirit/include/qi.hpp>
#include <boost/none.hpp>
#include <boost/cstdint.hpp>
#include <boost/fusion/include/adapt_struct.hpp>
#include <string>
#include <exception>
#include <vector>
namespace lex = boost::spirit::lex;
namespace px = boost::phoenix;
namespace qi = boost::spirit::qi;
namespace ascii = boost::spirit::ascii;
template <typename Lexer>
struct tokens : lex::lexer<Lexer>
{
tokens()
: left_curly("\"{\""),
right_curly("\"}\""),
left_paren("\"(\""),
right_paren("\")\""),
colon(":"),
scolon(";"),
namespace_("(?i:namespace)"),
event("(?i:event)"),
optional("(?i:optional)"), …
Run Code Online (Sandbox Code Playgroud) 我想在我正在做的一些数字运算中定义一些全局变量,我正在逐步编写脚本并且不希望以前的结果继续被加载/重新计算.一种方法是将成熟代码拆分为单独的文件,并且仅python run
交互式地将新代码拆分.但是我只想在单个文件中进行开发速度.
我假设文件中定义的全局在调用之间会持续存在run
,但它们不会.
所以我的脚本有以下块,如果代码:
if globals().has_key('all_post_freq') != True:
print "creating all post freq var"
global all_post_freq
all_post_freq = all_post_freq_("pickle/all_post_freq.pickle")
Run Code Online (Sandbox Code Playgroud)
如何在调用之间保留all_post_freq ipython run
编辑
好吧我把文件拆分成文件,但我知道必须有办法做我需要做的事情:D
我想创建一些帮助规则,这些规则采用一个规则并为其添加一些功能.例如,强制要求引用字符串文字,或者将令牌位置跟踪添加到令牌规则/ ADT.
我尝试了以下语法(以及相当多的排列).
def quoted[T](rl: Rule1[T]) = rule {
'"' ~ rl ~ '"'
}
Run Code Online (Sandbox Code Playgroud)
它编译得很好,但是一旦我将它连接起来 - 例如,
def NodeObjPathEntry: Rule1[CNodeObjPathEntry] = rule {
WhiteSpace ~ quoted(IdentifierStringUnwrapped) ~ ':' ~ (NodeObjArray | NodeObjObj) ~> CNodeObjPathEntry
}
Run Code Online (Sandbox Code Playgroud)
使用子规则:
def IdentifierStringUnwrapped: Rule1[String] = rule {
clearSB() ~ IdentifierChars ~ push(sb.toString)
}
def IdentifierChars = rule {
Alpha ~ appendSB() ~ zeroOrMore(AlphaNum ~ appendSB())
}
Run Code Online (Sandbox Code Playgroud)
我明白了 Illegal rule call: quoted[this.String](this.IdentifierStringUnwrapped)
我可以提交另一种方法:混合原始令牌解析器,然后创建我需要的变体.但我真的想知道发生了什么.
如何以符合人体工程学的方式继承所有配置的 BOM 约束?以下是我目前正在做的事情。我使用的是 Gradle 6.6.1。
dependencies {
compileOnly(platform('x:y:z'))
implementation(platform('x:y:z'))
annotationProcessor(platform('x:y:z'))
testAnnotationProcessor(platform('x:y:z'))
testImplementation(platform('x:y:z'))
testCompileOnly(platform('x:y:z'))
}
Run Code Online (Sandbox Code Playgroud) c++ ×4
parsing ×2
boost ×1
boost-spirit ×1
bson ×1
compilation ×1
datetime ×1
gcc ×1
gradle ×1
ipython ×1
lexer ×1
lua ×1
mongodb ×1
parboiled ×1
plpgsql ×1
postgresql ×1
python ×1
scala ×1
scala-macros ×1
sql-server ×1
toolchain ×1