What happened

Shares of Palantir Technologies (PLTR 0.56%) were firmly in rally mode on Tuesday, defying the overall market downtrend and spiking as much as 16.3%. As of 10:28 a.m. ET, the stock was still up 14.7%.

The catalyst that sent the machine learning software and data mining specialist higher was the company's quarterly financial report, which far exceeded expectations, leading to a surprise profit.

So what

For the fourth quarter, Palantir generated revenue to $509.1 million, up 18% year over year, fueled by strong government revenue, which climbed 23%. This helped drive positive net income, the first time the company has achieved profitability according to generally accepted accounting principles (GAAP). This resulted in earnings per share (EPS) of $0.01 and adjusted EPS of $0.04. Analysts' consensus estimates were calling for revenue of $502.6 million and adjusted EPS of $0.03, so the company sailed past investor expectations. 

Robust user metrics lay the foundation for the financial results, as its customer count soared to 367, up 55% year over year. The company also inked 976 new deals, an increase of 61% in the same time period. Not only did Palantir add a host of new customers, but its existing customers boosted spending, as evidenced by its net dollar retention rate of 124%.

Now what

While management acknowledges the uncertainty caused by deteriorating macroeconomic conditions, demand from existing customers remains strong, as Palantir helps them "do more with less," according to CFO David Glazer. 

The company expects to continue its growth. In the first quarter, Palantir is guiding for revenue of $505 million, up 13% at the midpoint of its guidance. For the full year, management is forecasting revenue growth of 16% to $2.2 billion. Perhaps more importantly for investors, Palantir expects to be net income positive for the full year. 

Palantir is still near its lowest valuation ever, though it still isn't cheap in terms of traditional valuation metrics. The stock currently sells for about 6 times next year's sales, when a reasonable price-to-sales ratio is between 1 and 2.

That said, strong growth in the face of adversity show that the demand for the company's industry-leading artificial intelligence (AI) and data mining capabilities will likely continue, no matter the economic climate. That makes Palantir stock a buy.